* 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.
* Fix#2157
* Fix Windows build error: wrap std::max in parentheses to avoid macro conflict
- On Windows, max/min are often defined as macros by windows.h
- This causes compilation errors with std::max/std::min
- Solution: use (std::max) to prevent macro expansion
- Fixes CI build error: error C2589: '(': illegal token on right side of '::'
Fixes: error in coalesce_ranges function on line 5376
* Adds headers to multipart form data
Adds a `headers` field to the `MultipartFormData` struct.
Populates this field by parsing headers from the multipart form data.
This allows access to specific headers associated with each form data part.
* Adds multipart header access test
Verifies the correct retrieval of headers from multipart form data file parts.
Ensures that custom and content-related headers are accessible and parsed as expected.
* Enables automatic test discovery with GoogleTest
Uses `gtest_discover_tests` to automatically find and run tests, simplifying test maintenance and improving discoverability.
* Removes explicit GoogleTest include
* Refactors header parsing logic
Improves header parsing by using a dedicated parsing function,
resulting in cleaner and more robust code.
This change also adds error handling during header parsing,
returning an error and marking the request as invalid
if parsing fails.
* clang-format corrected
* Renames variable for better readability.
Renames the `customHeader` variable to `custom_header` for improved code readability and consistency.
* typo
* fix(parser): Limit line length in getline
Prevents potential infinite loop and memory exhaustion in
stream_line_reader::getline by enforcing max line length.
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
* fix: increase default max line length to 32k
LONG_QUERY_VALUE test is set at 25k.
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
* test(client): expect read error with too long query
Adds a test case (`TooLongQueryValue`) to verify client behavior
when the request URI is excessively long, exceeding
`CPPHTTPLIB_MAX_LINE_LENGTH`. In this scenario, the server is
expected to reset the connection.
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
---------
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
afunix.h uses types declared in winsock2.h, and so has to be included
after it. Including afunix.h first will result in a somewhat unhelpful
compilation error:
error C3646: 'sun_family': unknown override specifier
Signed-off-by: Piotr Stankiewicz <piotr.stankiewicz@docker.com>
* Add zstd support
* Add zstd to CI tests
* Use use zstd cmake target instead of ZSTD. Use cmake variable for found packages
* Add missing comment for HTTPLIB_REQUIRE_ZSTD
* Fix test.yaml rebase error
* Use zstd::libzstd target
* Add include and library paths to ZSTD args
* Run clang-format
* Add zstd to httplibConfig.cmake.in
By making the random engine thread_local, each thread now has its own
independent random sequence, ensuring safe concurrent access.
Additionally, using an immediately invoked lambda expression to
initialize the engine eliminates the need for separate static seed
variables.
* Wrap poll()/WSAPoll() in a function
Instead of using a macro for poll() on Windows, which breaks when the
implementation is compiled separately, add a detail::poll_wrapper()
function that dispatches to either ::poll() or ::WSAPoll().
* Build compiled library on Windows
* Revert "Fix typo in meson.build (#2070)"
This reverts commit 5c0135fa5d.
* Revert "build(meson): automatically use poll or select as needed (#2067)"
This reverts commit 2b5d1eea8d.
* Revert "Make poll() the default (#2065)"
This reverts commit 6e73a63153.
* Remove select() and use poll()
- Replace is_readable() with wait_readable() and is_writable() with
wait_writable() in the Stream interface.
- Implement a new is_readable() function with semantics that more
closely reflect its name. It returns immediately whether data is
available for reading, without waiting.
- Update call sites of is_writable(), removing redundant checks.
* server_certificate_verifier extended to reuse built-in verifier
* code cleanup and SSLVerifierResponse enum clarification as per @falbrechtskirchinger comment
* cleanup
* clang-format
* change local var verification_status_ declaration to auto
* change local var verification_status_ to verification_status
* clang-format
* clang-format
---------
Co-authored-by: UrosG <uros@ub330.net>
Consider Content-Length and Transfer-Encoding headers when determining
whether to expect content. Don't handle the HTTP/2 connection preface
pseudo-method PRI.
Fixes#2028.