-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
While using this for a server and when the response body is bigger than 4096 bytes, an error occurs.
Buffer too large for blocking-write-and-flush (expected at most 4096)
We need to flush the body contents as soon as it is at 4096 bytes, so a good idea is to chunk the output.
Suggestion is to change the handle_response method in response.rs to the following:
pub fn handle_response(response_out: ResponseOutparam, response: Response) {
let outgoing_response = OutgoingResponse::new(response.headers.try_into().unwrap());
outgoing_response
.set_status_code(response.status_code)
.unwrap();
let outgoing_body = outgoing_response.body().unwrap();
ResponseOutparam::set(response_out, Ok(outgoing_response));
let body = response.body.bytes().unwrap();
if !body.is_empty() {
let out = outgoing_body.write().unwrap();
let chunks = body.chunks(4096);
for chunk in chunks {
out.blocking_write_and_flush(chunk)
.unwrap();
}
}
OutgoingBody::finish(outgoing_body, None).unwrap();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels