Commit 6a16b739 authored by jan.koester's avatar jan.koester
Browse files

phase1 completed

parent bb6242f0
Loading
Loading
Loading
Loading
+2 −0
Changes for src/hpack.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -423,6 +423,7 @@ std::string Encoder::encodeResponseHeaders(uint16_t status_code,
                                           size_t content_length,
                                           const std::vector<HeaderField> &extra) {
    std::string out;
    out.reserve(64 + extra.size() * 48); // rough per-field estimate, avoids reallocation churn

    if (status_code == 200) {
        out.push_back(static_cast<char>(0x88));  // index 8
@@ -462,6 +463,7 @@ std::string Encoder::encodeRequestHeaders(const std::string &method,
                                           const std::string &authority,
                                           const std::vector<HeaderField> &extra) {
    std::string out;
    out.reserve(64 + extra.size() * 48); // rough per-field estimate, avoids reallocation churn

    // :method — static table index 2 = GET, 3 = POST
    if (method == "GET") {
+9 −0
Changes for src/http.cpp: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -811,6 +811,7 @@ libhttppp::HttpResponse libhttppp::HttpClient::GetStream(libhttppp::HttpRequest
        // Reset any previous streaming state
        _streamMode = STREAM_NONE;
        _streamBuf.clear();
        _streamBuf.reserve(CHUNKSIZE);
        _streamBufPos = 0;
        _streamRemaining = 0;
        _streamChunkDone = false;
@@ -818,10 +819,13 @@ libhttppp::HttpResponse libhttppp::HttpClient::GetStream(libhttppp::HttpRequest
        _streamH2Sid = 0;
        _streamH2EndStream = false;
        _streamH2Raw.clear();
        _streamH2Raw.reserve(CHUNKSIZE);
        _streamH3Sid = 0;
        _streamH3EndStream = false;
        _streamH3Raw.clear();
        _streamH3Raw.reserve(CHUNKSIZE);
        _streamH3Body.clear();
        _streamH3Body.reserve(CHUNKSIZE);
        _streamH3BodyPos = 0;
        _streamH3InDataFrame = false;
        _streamH3DataRemaining = 0;
@@ -1304,6 +1308,7 @@ libhttppp::HttpResponse libhttppp::HttpClient::PostStream(libhttppp::HttpRequest
        // Reset any previous streaming state (mirrors GetStream)
        _streamMode = STREAM_NONE;
        _streamBuf.clear();
        _streamBuf.reserve(CHUNKSIZE);
        _streamBufPos = 0;
        _streamRemaining = 0;
        _streamChunkDone = false;
@@ -1311,10 +1316,13 @@ libhttppp::HttpResponse libhttppp::HttpClient::PostStream(libhttppp::HttpRequest
        _streamH2Sid = 0;
        _streamH2EndStream = false;
        _streamH2Raw.clear();
        _streamH2Raw.reserve(CHUNKSIZE);
        _streamH3Sid = 0;
        _streamH3EndStream = false;
        _streamH3Raw.clear();
        _streamH3Raw.reserve(CHUNKSIZE);
        _streamH3Body.clear();
        _streamH3Body.reserve(CHUNKSIZE);
        _streamH3BodyPos = 0;
        _streamH3InDataFrame = false;
        _streamH3DataRemaining = 0;
@@ -4509,6 +4517,7 @@ int libhttppp::HttpRequest::decodeChunkedBody(){
  const char *d = RecvData.data();
  const size_t n = RecvData.size();
  std::string body;
  body.reserve(n); // decoded body can't exceed the raw (chunk-framed) input size
  size_t pos = 0;

  // Hard cap to avoid unbounded growth from a hostile peer (2 GiB).
+2 −0
Changes for src/qpack.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -282,6 +282,7 @@ std::vector<uint8_t> Encoder::encodeResponseHeaders(uint16_t status_code,
                                                    size_t content_length,
                                                    const std::vector<HeaderField> &extra) {
    std::vector<uint8_t> out;
    out.reserve(64 + extra.size() * 48); // rough per-field estimate, avoids reallocation churn

    // Section prefix: Required Insert Count = 0, S=0, Delta Base = 0
    out.push_back(0x00);
@@ -344,6 +345,7 @@ std::vector<uint8_t> Encoder::encodeRequestHeaders(const std::string &method,
                                                   bool include_content_length,
                                                   size_t content_length) {
    std::vector<uint8_t> out;
    out.reserve(64 + extra.size() * 48); // rough per-field estimate, avoids reallocation churn

    // Section prefix: Required Insert Count = 0, S=0, Delta Base = 0
    out.push_back(0x00);