Loading src/http.cpp +168 −140 Original line number Diff line number Diff line Loading @@ -2133,8 +2133,10 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( } } const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible (avoid expensive TLS handshakes) _ensureConnected(); Loading Loading @@ -2180,15 +2182,22 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) } } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq, const std::vector<char> &post) const std::vector<char> &post, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2232,14 +2241,21 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq return _h1ReadResponse("POST"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nreq) const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nreq, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2276,15 +2292,22 @@ const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nr return _h1ReadResponse("DELETE"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Put(libhttppp::HttpRequest &nreq, const std::vector<char> &put) const std::vector<char> &put, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2328,10 +2351,15 @@ const std::vector<char> libhttppp::HttpClient::Put(libhttppp::HttpRequest &nreq, return _h1ReadResponse("PUT"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } int libhttppp::HttpClient::readchunk(const char *data, int datasize, int &pos) Loading src/http.h +4 −4 Original line number Diff line number Diff line Loading @@ -89,10 +89,10 @@ namespace libhttppp { HttpClient( const HttpUrl &desturl); ~HttpClient()=default; void reconnect(); const std::vector<char> Get(HttpRequest &nreq); const std::vector<char> Post(HttpRequest &nreq,const std::vector<char> &post); const std::vector<char> Put(HttpRequest &nreq,const std::vector<char> &put); const std::vector<char> Delete(HttpRequest &nreq); const std::vector<char> Get(HttpRequest &nreq, size_t maxTries=0); const std::vector<char> Post(HttpRequest &nreq,const std::vector<char> &post, size_t maxTries=0); const std::vector<char> Put(HttpRequest &nreq,const std::vector<char> &put, size_t maxTries=0); const std::vector<char> Delete(HttpRequest &nreq, size_t maxTries=0); // Streaming API: send request, return parsed response headers only. // After this call, use readBodyChunk() to read body data incrementally. Loading Loading
src/http.cpp +168 −140 Original line number Diff line number Diff line Loading @@ -2133,8 +2133,10 @@ const std::vector<char> libhttppp::HttpClient::_h2Request( } } const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible (avoid expensive TLS handshakes) _ensureConnected(); Loading Loading @@ -2180,15 +2182,22 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) } } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq, const std::vector<char> &post) const std::vector<char> &post, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2232,14 +2241,21 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq return _h1ReadResponse("POST"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nreq) const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nreq, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2276,15 +2292,22 @@ const std::vector<char> libhttppp::HttpClient::Delete(libhttppp::HttpRequest &nr return _h1ReadResponse("DELETE"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } const std::vector<char> libhttppp::HttpClient::Put(libhttppp::HttpRequest &nreq, const std::vector<char> &put) const std::vector<char> &put, size_t maxTries) { size_t tries = 0; for (;;) { try { // Reuse existing connection if possible _ensureConnected(); Loading Loading @@ -2328,10 +2351,15 @@ const std::vector<char> libhttppp::HttpClient::Put(libhttppp::HttpRequest &nreq, return _h1ReadResponse("PUT"); } catch (netplus::NetException &e) { ++tries; if (maxTries != 0 && tries >= maxTries) { libhttppp::HTTPException ee; ee[libhttppp::HTTPException::Error] << e.what(); throw ee; } resetConnection(); } } } int libhttppp::HttpClient::readchunk(const char *data, int datasize, int &pos) Loading
src/http.h +4 −4 Original line number Diff line number Diff line Loading @@ -89,10 +89,10 @@ namespace libhttppp { HttpClient( const HttpUrl &desturl); ~HttpClient()=default; void reconnect(); const std::vector<char> Get(HttpRequest &nreq); const std::vector<char> Post(HttpRequest &nreq,const std::vector<char> &post); const std::vector<char> Put(HttpRequest &nreq,const std::vector<char> &put); const std::vector<char> Delete(HttpRequest &nreq); const std::vector<char> Get(HttpRequest &nreq, size_t maxTries=0); const std::vector<char> Post(HttpRequest &nreq,const std::vector<char> &post, size_t maxTries=0); const std::vector<char> Put(HttpRequest &nreq,const std::vector<char> &put, size_t maxTries=0); const std::vector<char> Delete(HttpRequest &nreq, size_t maxTries=0); // Streaming API: send request, return parsed response headers only. // After this call, use readBodyChunk() to read body data incrementally. Loading