-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iostream/http: Fix output_stream::write(temporary_buffer) overload
Previously, calling the 'write(temporary_buffer<char>)' overload on an output_stream<char> obtained from http::reply::write_body would cause an abort. This commit fixes this by providing a helper function (in the data_sink_impl base class) named 'fallback_put', which classes that inherit from this base class can use to implement the 'put(net::packet)' overload. Also, this commit lets http_chunked_data_sink_impl and http_content_length_data_sink_impl make use of this helper. fallback_put(net::packet) works simply by extracting the temporary_buffers contained in the packet, and calling the 'put(temporary_buffer<char>)' overload for each temporary_buffer. Note that we create this 'fallback_put' function instead of defining the virtual member 'put(net::packet)' function in the data_sink_impl class, to avoid 'put(net::packet)' and 'put(temporary_buffer<char>)' calling each other leading to infinite recursion. This commit also adds a unit test to tests/unit/httpd_test.cc Thanks to Pavel (xemul) for his help. Fixes #1701
- Loading branch information
Niek Bouman
committed
Sep 16, 2024
1 parent
f03f7df
commit 52eb058
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters