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
For efficiency and to avoid allocations, I may want the ability to pre-allocate buffers and provide them to HTTP.request to be used directly when writing a response.
I'm not exactly sure the best interface for this, but we already have response_stream where the user can provide an IO that we write the response body to. So one option might be that the user can just provide an AbstractVector{UInt8} to response_stream and then we either use that directly or wrap it in some internal wrapper struct that is handled specially when writing.
One piece I haven't quite thought through either is what to do about the size of the buffer vs. size of the response body. What if the user-provided buffer is too small? or too big? do we somehow signal this and what is the best way to do that?
Also as an overall thought, it would be ideal if we could get to a scenario where HTTP.request can potentially avoid any allocations at all, but I'm not quite sure what all the current allocations involve, so I'm not sure how feasible this actually is; just something to think about.
The text was updated successfully, but these errors were encountered:
This is now supported by passing an exactly right-size Vector{UInt8} as the response_stream arg, or an IOBuffer as the response_stream (which can wrap a pre-allocated Vector{UInt8}) and the IOBuffer will be grown (if write is allowed) and the # of bytes will be recorded by the IOBuffer if the Vector{UInt8} isn't fully used.
For efficiency and to avoid allocations, I may want the ability to pre-allocate buffers and provide them to HTTP.request to be used directly when writing a response.
I'm not exactly sure the best interface for this, but we already have
response_stream
where the user can provide an IO that we write the response body to. So one option might be that the user can just provide anAbstractVector{UInt8}
toresponse_stream
and then we either use that directly or wrap it in some internal wrapper struct that is handled specially when writing.One piece I haven't quite thought through either is what to do about the size of the buffer vs. size of the response body. What if the user-provided buffer is too small? or too big? do we somehow signal this and what is the best way to do that?
Also as an overall thought, it would be ideal if we could get to a scenario where
HTTP.request
can potentially avoid any allocations at all, but I'm not quite sure what all the current allocations involve, so I'm not sure how feasible this actually is; just something to think about.The text was updated successfully, but these errors were encountered: