Loading src/http.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -247,10 +247,12 @@ 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 @@ -1069,6 +1071,9 @@ 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 @@ -1081,6 +1086,7 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( auto last_activity = last_data; const auto idle_timeout = std::chrono::seconds(15); const auto response_timeout = std::chrono::seconds(60); int loop_iter = 0; for (;;) { uint8_t buf[4096]; Loading @@ -1089,15 +1095,19 @@ 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 @@ -1107,6 +1117,10 @@ 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) { Loading @@ -1114,6 +1128,7 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( continue; } } ++loop_iter; size_t pos = 0; while (pos < raw.size()) { Loading Loading @@ -1153,23 +1168,35 @@ 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 Loading
src/http.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -247,10 +247,12 @@ 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 @@ -1069,6 +1071,9 @@ 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 @@ -1081,6 +1086,7 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( auto last_activity = last_data; const auto idle_timeout = std::chrono::seconds(15); const auto response_timeout = std::chrono::seconds(60); int loop_iter = 0; for (;;) { uint8_t buf[4096]; Loading @@ -1089,15 +1095,19 @@ 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 @@ -1107,6 +1117,10 @@ 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) { Loading @@ -1114,6 +1128,7 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( continue; } } ++loop_iter; size_t pos = 0; while (pos < raw.size()) { Loading Loading @@ -1153,23 +1168,35 @@ 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