Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A fix for receive response #77

Open
wqqn99 opened this issue Apr 16, 2024 · 0 comments
Open

A fix for receive response #77

wqqn99 opened this issue Apr 16, 2024 · 0 comments

Comments

@wqqn99
Copy link

wqqn99 commented Apr 16, 2024

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();
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant