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
How does this interact with using the serializer? If not using the serializer it will be an addional memcpy for the body compared to using a sink with prepare() right?
How does this interact with using the serializer? If not using the serializer it will be an addional memcpy for the body compared to using a sink with prepare() right?
Yes, it currently makes a copy, but this is exactly what I'm currently working on in the boost.burl project (the work there will eventually be merged into this project). While the interface will remain pretty much the same, it won't make a copy.
This is already resolved on the parser side, although the changes haven't been merged into this project yet.
The doc for res_body needs to be changed. I thought you could attach it if you wanted a body, but you actually have to set it to a sink from your socket otherwise you get a null pointer dereference in send.
/// Provides access to the response body
http::any_buffer_sink res_body;
Ideally this would be a compile time failure too, or some error, not an exception directly.
Activity
vinniefalco commentedon Aug 13, 2026
@ashtum why
ashtum commentedon Aug 13, 2026
This is after refactoring the router to use coroutines. The new way of doing it is:
You can also use rp.res_body to stream the body incrementally (that’s what’s happening in
static_server.cpp).The docs need updating. I’ll work on them after I’m done with the Burl serializer (next week).
R-Goc commentedon Aug 13, 2026
How does this interact with using the serializer? If not using the serializer it will be an addional memcpy for the body compared to using a sink with prepare() right?
ashtum commentedon Aug 13, 2026
Yes, it currently makes a copy, but this is exactly what I'm currently working on in the boost.burl project (the work there will eventually be merged into this project). While the interface will remain pretty much the same, it won't make a copy.
This is already resolved on the parser side, although the changes haven't been merged into this project yet.
R-Goc commentedon Aug 13, 2026
The body I pass to rp.send must already be serialised right?
ashtum commentedon Aug 13, 2026
Yes, the string_view passed to
sendwill be used as the body of the response, withContent-Lengthset to the same size as the string_view.Structural types, like Boost.JSON types, can benefit from the streaming interface. So, in the future, you could do:
And it will serialize the json value in-place (using the serialzier's internal buffer).
R-Goc commentedon Aug 14, 2026
The doc for res_body needs to be changed. I thought you could attach it if you wanted a body, but you actually have to set it to a sink from your socket otherwise you get a null pointer dereference in send.
Ideally this would be a compile time failure too, or some error, not an exception directly.