Commit 1faf88df authored by jan.koester's avatar jan.koester
Browse files

h3 reset build in

parent 380fc212
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -969,6 +969,11 @@ libhttppp::HttpResponse libhttppp::HttpClient::GetStream(libhttppp::HttpRequest
                        if (!got_any) {
                            if (q->isStreamComplete(stream_id) && !q->hasStreamData(stream_id))
                                break;
                            if (q->isStreamReset(stream_id)) {
                                HTTPException ee;
                                ee[HTTPException::Error] << "HTTP/3 stream aborted by peer";
                                throw ee;
                            }
                            if (std::chrono::steady_clock::now() >= h3_header_deadline) {
                                HTTPException ee;
                                ee[HTTPException::Error] << "HTTP/3 header timeout";
@@ -1898,6 +1903,16 @@ size_t libhttppp::HttpClient::readBodyChunk(char *buf, size_t bufsize) {
                        _streamMode = STREAM_NONE;
                        return 0;
                    }
                    if (q->isStreamReset(_streamH3Sid)) {
                        // Upstream aborted mid-body (e.g. it stalled short of
                        // the advertised Content-Length). Surface this as an
                        // error rather than silently handing back a
                        // truncated body (a partially-decoded image, etc).
                        _streamMode = STREAM_NONE;
                        HTTPException ee;
                        ee[HTTPException::Error] << "HTTP/3 stream aborted by peer";
                        throw ee;
                    }
                    if (std::chrono::steady_clock::now() >= deadline) {
                        HTTPException ee;
                        ee[HTTPException::Error] << "HTTP/3 stream read timeout";
+7 −1
Original line number Diff line number Diff line
@@ -1410,7 +1410,13 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock,
                }

                if (sent < content_length) {
                    q->sendStreamData(stream_id, nullptr, 0, true);
                    // Genuine stall with the response short of the
                    // advertised Content-Length. Sending FIN here would make
                    // the client accept a truncated body as complete (e.g. a
                    // corrupted image). Abort the stream instead so the
                    // client sees a failed transfer, mirroring the H2 stall
                    // handling above.
                    q->resetStream(stream_id, 0x0102); // H3_INTERNAL_ERROR
                }
            }).detach();