Commit 255ae392 authored by jan.koester's avatar jan.koester
Browse files

fixes

parent 3481eefd
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -1078,7 +1078,9 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
      std::string location;

      auto last_data = std::chrono::steady_clock::now();
      auto last_activity = last_data;
      const auto idle_timeout = std::chrono::seconds(15);
      const auto response_timeout = std::chrono::seconds(60);

      for (;;) {
        uint8_t buf[4096];
@@ -1086,6 +1088,7 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
        if (n > 0) {
          raw.insert(raw.end(), buf, buf + n);
          last_data = std::chrono::steady_clock::now();
          last_activity = last_data;
        } else {
          // Pump the UDP socket: drain ALL available datagrams and process
          // QUIC packets. For large responses the server sends many datagrams;
@@ -1104,9 +1107,10 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
              break; // EAGAIN — no more datagrams available
            }
          }
          // Any pumped packet (including PING) means the connection is alive
          // Any pumped packet (including PING) keeps the connection alive
          // but does NOT reset the response data timeout
          if (pumped_any) {
            last_data = std::chrono::steady_clock::now();
            last_activity = std::chrono::steady_clock::now();
            continue;
          }
        }
@@ -1159,7 +1163,13 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
          break;
        }

        if (std::chrono::steady_clock::now() - last_data > idle_timeout) {
        auto now = std::chrono::steady_clock::now();
        if (now - last_activity > idle_timeout) {
          HTTPException ee;
          ee[HTTPException::Error] << "HTTP/3 connection idle timeout";
          throw ee;
        }
        if (now - last_data > response_timeout) {
          HTTPException ee;
          ee[HTTPException::Error] << "HTTP/3 response timeout";
          throw ee;