mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-17 10:59:39 +00:00
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:
1 parent
b6c55c6030
commit
de5a255ac6
2 files changed
+57
-4
No files matched your search
@@ -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