Loading src/http.cpp +7 −28 Original line number Diff line number Diff line Loading @@ -247,12 +247,10 @@ bool libhttppp::HttpClient::tryHttp3First(){ _cltsock = std::move(q); _isH2 = false; fprintf(stderr, "[H3-CLT] tryHttp3First: SUCCESS (handshake done)\n"); return true; } catch (netplus::NetException&) { _cltsock.reset(); _isH2 = false; fprintf(stderr, "[H3-CLT] tryHttp3First: FAILED (exception)\n"); return false; } } Loading Loading @@ -1071,9 +1069,6 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( uint64_t stream_id = q->openStream(true); q->sendStreamData(stream_id, stream_payload, true); fprintf(stderr, "[H3-CLT] sent %s %s stream=%llu payload=%zu\n", method.c_str(), path.c_str(), (unsigned long long)stream_id, stream_payload.size()); std::vector<uint8_t> raw; std::vector<char> body; Loading @@ -1095,19 +1090,15 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( raw.insert(raw.end(), buf, buf + n); last_data = std::chrono::steady_clock::now(); last_activity = last_data; fprintf(stderr, "[H3-CLT] recv stream=%llu +%zu bytes (raw=%zu)\n", (unsigned long long)stream_id, n, raw.size()); } else { // Pump the UDP socket: drain ALL available datagrams and process // QUIC packets. For large responses the server sends many datagrams; // reading only one per loop iteration would be far too slow. bool pumped_any = false; int pump_count = 0; for (int pump_i = 0; pump_i < 256; ++pump_i) { try { q->pumpNetwork(MSG_DONTWAIT); pumped_any = true; ++pump_count; } catch (netplus::NetException &e) { if (e.getErrorType() != netplus::NetException::Note) { HTTPException ee; Loading @@ -1117,15 +1108,15 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( break; // EAGAIN — no more datagrams available } } if (loop_iter < 5 || (loop_iter % 50 == 0)) { fprintf(stderr, "[H3-CLT] loop=%d pumped=%d(%d) raw=%zu body=%zu hdr=%d\n", loop_iter, pumped_any?1:0, pump_count, raw.size(), body.size(), got_headers?1:0); } // Any pumped packet (including PING) keeps the connection alive // but does NOT reset the response data timeout if (pumped_any) { last_activity = std::chrono::steady_clock::now(); continue; // After pumping, try to read stream data before waiting n = q->recvStreamData(stream_id, buf, sizeof(buf)); if (n > 0) { raw.insert(raw.end(), buf, buf + n); last_data = std::chrono::steady_clock::now(); last_activity = last_data; } } } ++loop_iter; Loading Loading @@ -1169,35 +1160,23 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( } if (got_headers && expected_body != static_cast<size_t>(-1) && body.size() >= expected_body) { fprintf(stderr, "[H3-CLT] COMPLETE status=%d body=%zu/%zu\n", status_code, body.size(), expected_body); ret = std::move(body); break; } if (got_headers && expected_body == static_cast<size_t>(-1) && q->isStreamComplete(stream_id) && raw.empty()) { fprintf(stderr, "[H3-CLT] COMPLETE (stream-fin) status=%d body=%zu\n", status_code, body.size()); ret = std::move(body); break; } auto now = std::chrono::steady_clock::now(); auto idle_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activity).count(); auto data_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_data).count(); if (loop_iter < 5 || (loop_iter % 50 == 0)) { fprintf(stderr, "[H3-CLT] timeout-chk loop=%d idle=%ldms data=%ldms\n", loop_iter, (long)idle_ms, (long)data_ms); } if (now - last_activity > idle_timeout) { fprintf(stderr, "[H3-CLT] IDLE TIMEOUT after %ldms\n", (long)idle_ms); HTTPException ee; ee[HTTPException::Error] << "HTTP/3 connection idle timeout"; throw ee; } if (now - last_data > response_timeout) { fprintf(stderr, "[H3-CLT] RESPONSE TIMEOUT after %ldms\n", (long)data_ms); HTTPException ee; ee[HTTPException::Error] << "HTTP/3 response timeout"; throw ee; Loading src/httpd.cpp +0 −6 Original line number Diff line number Diff line Loading @@ -818,8 +818,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, // Read structured response info from :res-* pseudo-headers auto *resValid = tempreq.getHeaderData(":res-valid"); fprintf(stderr, "[H3-RESP] resValid=%p stream=%llu\n", (void*)resValid, (unsigned long long)stream_id); if (resValid && resValid->getfirstValue()) { // Extract status code uint16_t status_code = 200; Loading Loading @@ -891,8 +889,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, std::vector<uint8_t> response = h3BuildResponse( status_code, body, content_type.empty() ? "text/html" : content_type, extra); fprintf(stderr, "[H3-RESP] sending %zu bytes on stream=%llu status=%u\n", response.size(), (unsigned long long)stream_id, status_code); q->sendStreamData(stream_id, response, true); // Clean up :res-* pseudo-headers Loading @@ -901,8 +897,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, tempreq.deldata(":res-content-type"); tempreq.deldata(":res-content-length"); } else { fprintf(stderr, "[H3-RESP] NO :res-valid header — no response sent for stream=%llu\n", (unsigned long long)stream_id); } } Loading Loading
src/http.cpp +7 −28 Original line number Diff line number Diff line Loading @@ -247,12 +247,10 @@ bool libhttppp::HttpClient::tryHttp3First(){ _cltsock = std::move(q); _isH2 = false; fprintf(stderr, "[H3-CLT] tryHttp3First: SUCCESS (handshake done)\n"); return true; } catch (netplus::NetException&) { _cltsock.reset(); _isH2 = false; fprintf(stderr, "[H3-CLT] tryHttp3First: FAILED (exception)\n"); return false; } } Loading Loading @@ -1071,9 +1069,6 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( uint64_t stream_id = q->openStream(true); q->sendStreamData(stream_id, stream_payload, true); fprintf(stderr, "[H3-CLT] sent %s %s stream=%llu payload=%zu\n", method.c_str(), path.c_str(), (unsigned long long)stream_id, stream_payload.size()); std::vector<uint8_t> raw; std::vector<char> body; Loading @@ -1095,19 +1090,15 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( raw.insert(raw.end(), buf, buf + n); last_data = std::chrono::steady_clock::now(); last_activity = last_data; fprintf(stderr, "[H3-CLT] recv stream=%llu +%zu bytes (raw=%zu)\n", (unsigned long long)stream_id, n, raw.size()); } else { // Pump the UDP socket: drain ALL available datagrams and process // QUIC packets. For large responses the server sends many datagrams; // reading only one per loop iteration would be far too slow. bool pumped_any = false; int pump_count = 0; for (int pump_i = 0; pump_i < 256; ++pump_i) { try { q->pumpNetwork(MSG_DONTWAIT); pumped_any = true; ++pump_count; } catch (netplus::NetException &e) { if (e.getErrorType() != netplus::NetException::Note) { HTTPException ee; Loading @@ -1117,15 +1108,15 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( break; // EAGAIN — no more datagrams available } } if (loop_iter < 5 || (loop_iter % 50 == 0)) { fprintf(stderr, "[H3-CLT] loop=%d pumped=%d(%d) raw=%zu body=%zu hdr=%d\n", loop_iter, pumped_any?1:0, pump_count, raw.size(), body.size(), got_headers?1:0); } // Any pumped packet (including PING) keeps the connection alive // but does NOT reset the response data timeout if (pumped_any) { last_activity = std::chrono::steady_clock::now(); continue; // After pumping, try to read stream data before waiting n = q->recvStreamData(stream_id, buf, sizeof(buf)); if (n > 0) { raw.insert(raw.end(), buf, buf + n); last_data = std::chrono::steady_clock::now(); last_activity = last_data; } } } ++loop_iter; Loading Loading @@ -1169,35 +1160,23 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( } if (got_headers && expected_body != static_cast<size_t>(-1) && body.size() >= expected_body) { fprintf(stderr, "[H3-CLT] COMPLETE status=%d body=%zu/%zu\n", status_code, body.size(), expected_body); ret = std::move(body); break; } if (got_headers && expected_body == static_cast<size_t>(-1) && q->isStreamComplete(stream_id) && raw.empty()) { fprintf(stderr, "[H3-CLT] COMPLETE (stream-fin) status=%d body=%zu\n", status_code, body.size()); ret = std::move(body); break; } auto now = std::chrono::steady_clock::now(); auto idle_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activity).count(); auto data_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_data).count(); if (loop_iter < 5 || (loop_iter % 50 == 0)) { fprintf(stderr, "[H3-CLT] timeout-chk loop=%d idle=%ldms data=%ldms\n", loop_iter, (long)idle_ms, (long)data_ms); } if (now - last_activity > idle_timeout) { fprintf(stderr, "[H3-CLT] IDLE TIMEOUT after %ldms\n", (long)idle_ms); HTTPException ee; ee[HTTPException::Error] << "HTTP/3 connection idle timeout"; throw ee; } if (now - last_data > response_timeout) { fprintf(stderr, "[H3-CLT] RESPONSE TIMEOUT after %ldms\n", (long)data_ms); HTTPException ee; ee[HTTPException::Error] << "HTTP/3 response timeout"; throw ee; Loading
src/httpd.cpp +0 −6 Original line number Diff line number Diff line Loading @@ -818,8 +818,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, // Read structured response info from :res-* pseudo-headers auto *resValid = tempreq.getHeaderData(":res-valid"); fprintf(stderr, "[H3-RESP] resValid=%p stream=%llu\n", (void*)resValid, (unsigned long long)stream_id); if (resValid && resValid->getfirstValue()) { // Extract status code uint16_t status_code = 200; Loading Loading @@ -891,8 +889,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, std::vector<uint8_t> response = h3BuildResponse( status_code, body, content_type.empty() ? "text/html" : content_type, extra); fprintf(stderr, "[H3-RESP] sending %zu bytes on stream=%llu status=%u\n", response.size(), (unsigned long long)stream_id, status_code); q->sendStreamData(stream_id, response, true); // Clean up :res-* pseudo-headers Loading @@ -901,8 +897,6 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock, tempreq.deldata(":res-content-type"); tempreq.deldata(":res-content-length"); } else { fprintf(stderr, "[H3-RESP] NO :res-valid header — no response sent for stream=%llu\n", (unsigned long long)stream_id); } } Loading