elnormous/HTTPRequest

A fix for receive response

wqqn99 opened this issue · 0 comments

Fix problem when receive partly response packet:

diff --git a/thirdparty/HTTPRequest/include/HTTPRequest.hpp b/thirdparty/HTTPRequest/include/HTTPRequest.hpp
index c446e216..1c559632 100644
--- a/thirdparty/HTTPRequest/include/HTTPRequest.hpp
+++ b/thirdparty/HTTPRequest/include/HTTPRequest.hpp
@@ -1198,6 +1198,7 @@ namespace http
bool removeCrlfAfterChunk = false;

         // read the response
  •      int header_recv_times = 0;
           for (;;)
           {
               const auto size = socket.recv(tempBuffer.data(), tempBuffer.size(),
    

@@ -1213,7 +1214,16 @@ namespace http
// Empty line indicates the end of the header section (RFC 7230, 2.1. Client/Server Messaging)
const auto endIterator = std::search(responseData.cbegin(), responseData.cend(),
headerEnd.cbegin(), headerEnd.cend());

  •                if (endIterator == responseData.cend()) break; // two consecutive CRLFs not found
    
  •                if (endIterator == responseData.cend())
    
  •                {
    
  •                        if (header_recv_times < 3)
    
  •                        {
    
  •                            header_recv_times++;
    
  •                            continue;
    
  •                        }
    
  •                        else
    
  •                            break;  // two consecutive CRLFs not found
    
  •                }
    
                   const auto headerBeginIterator = responseData.cbegin();