You've already forked cpp-httplib
Fix bad request for multipart form data with boundary split (#2159)
* Add test for multipart form data with boundary split Add a test for multipart form data requests with a large header which leads to a split inside the boundary because of the read buffer size inside the SocketStream class. * Fix bad request for multipart form data with boundary split Fix a bad request (400) response for multipart form data requests with a large header which leads to a split inside the boundary because of the read buffer size inside the SocketStream class. The parse function inside the MultipartFormDataParser wrongly erase the receive buffer if it doesn't find the boundary inside the buffer during first call.
This commit is contained in:
@ -5028,10 +5028,9 @@ public:
|
||||
while (buf_size() > 0) {
|
||||
switch (state_) {
|
||||
case 0: { // Initial boundary
|
||||
buf_erase(buf_find(dash_boundary_crlf_));
|
||||
if (dash_boundary_crlf_.size() > buf_size()) { return true; }
|
||||
if (!buf_start_with(dash_boundary_crlf_)) { return false; }
|
||||
buf_erase(dash_boundary_crlf_.size());
|
||||
auto pos = buf_find(dash_boundary_crlf_);
|
||||
if (pos == buf_size()) { return true; }
|
||||
buf_erase(pos + dash_boundary_crlf_.size());
|
||||
state_ = 1;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user