Skip to content

A fix for receive response #77

Description

@wqqn99

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();
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions