You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the library (as a client) against an API that makes use of Trailing headers in some of its chunked responses. The current code does not handle that case and I get a Read error instead.
I have tried to minimally modify the chunked reader code to validate my assumption. Using the following patch I no longer get a Read error and I can use the actual response correctly.
diff --git a/httplib.h b/httplib.h
index 7431dea..4401be4 100644
--- a/httplib.h+++ b/httplib.h@@ -3507,9 +3507,11 @@ inline bool read_content_chunked(Stream &strm,
}
if (chunk_len == 0) {
- // Reader terminator after chunks- if (!line_reader.getline() || strcmp(line_reader.ptr(), "\r\n"))- return false;+ // Read trailing headers until terminator+ while(!line_reader.getline())+ {+ if (strcmp(line_reader.ptr(), "\r\n")) { break; }+ }
}
return true;
This is a very crude approach that just ignores any trailing header. One might want to validate the trailing header names against the provided Trailer header value and then put those trailing headers in the response for potential use.
Is there any chance to get some form of fix for trailing headers in the library? I might have some time to do a PR if I get some advice on what needs to be done (just ignore trailing headers, add them to the response, validate them,...?)
The text was updated successfully, but these errors were encountered:
I use the library (as a client) against an API that makes use of Trailing headers in some of its chunked responses. The current code does not handle that case and I get a
Read
error instead.I have tried to minimally modify the chunked reader code to validate my assumption. Using the following patch I no longer get a
Read
error and I can use the actual response correctly.This is a very crude approach that just ignores any trailing header. One might want to validate the trailing header names against the provided
Trailer
header value and then put those trailing headers in the response for potential use.Is there any chance to get some form of fix for trailing headers in the library? I might have some time to do a PR if I get some advice on what needs to be done (just ignore trailing headers, add them to the response, validate them,...?)
The text was updated successfully, but these errors were encountered: