Commit 1005341a authored by jan.koester's avatar jan.koester
Browse files

bugfix

parent beed56ca
Loading
Loading
Loading
Loading
+1 −28
Original line number Diff line number Diff line
@@ -2803,10 +2803,6 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
      throw ee;
    }

    const int kMaxRedirects = 1;
    int redirects = 0;

    for (;;) {
    std::string path = nreq.getRequestURL();
      if (path.empty()) path = _url.getPath();

@@ -2856,8 +2852,6 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
      std::vector<char> body;
      bool got_headers = false;
      size_t expected_body = static_cast<size_t>(-1);
      int status_code = 0;
      std::string location;
      bool in_data_frame = false;
      uint64_t data_remaining = 0;
      size_t raw_off = 0; // consumed offset into raw (avoids erase-from-front)
@@ -2961,14 +2955,12 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
            _lastResponse = std::make_unique<HttpResponse>();
            _lastResponse->parseH3(decoded);
            _lastStatusCode = _lastResponse->getStatusCode();
            status_code = _lastStatusCode;
            _lastContentType = _lastResponse->getContentType();
            _lastLocation.clear();
            try {
                auto *loc = _lastResponse->getHeaderData("location");
                if (loc && loc->getfirstValue()) {
                    _lastLocation = loc->getfirstValue()->getvalue();
                    location = _lastLocation;
                }
            } catch (...) {}
            try {
@@ -3024,27 +3016,8 @@ const std::vector<char> libhttppp::HttpClient::_h2Request(
        }
      }

      if (is_redirect_status(status_code) && redirects < kMaxRedirects && !location.empty()) {
        ++redirects;
        if (location.rfind("http://", 0) == 0 || location.rfind("https://", 0) == 0) {
          _url = HttpUrl(location, false);
          nreq.setRequestURL(_url.getPath());
        } else {
          std::string base = nreq.getRequestURL().empty() ? _url.getPath() : nreq.getRequestURL();
          nreq.setRequestURL(normalize_path(location, base));
        }

        resetConnection();
        q = dynamic_cast<netplus::quic*>(_cltsock.get());
        if (!q) {
          return ret;
        }
        continue;
      }

      return ret;
  }
  }

const std::vector<char> libhttppp::HttpClient::_doH1Request(
    const std::string &method, int requestType, libhttppp::HttpRequest &nreq,