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
Hi, I'm building an api gateway.
And inside my proxy method i have this code section. I want to know what is the right way of reading and sending in chunks instead of load all the body in memory. Could you help me, I wasn't able to find a method to load the body in chunks
let client = reqwest::Client::new();letmut request_to_destination_server_builder = client
.request(req.method().clone(),&destination_url).query(req.queries()).headers(req.headers().clone());// If request have content length put that body in the request to// destination serverif req.headers().get("Content-Length").is_some(){let payload = match req.payload_with_max_size(MAX_SIZE_BODY).await{//Cloning the req.payload() is ok because it just clones the Bytes object and not the internal//buffer (buffer is where all the bytes of the body are stored)Ok(v) => v.clone(),Err(e) => {eprintln!("{}",e);
res.status_code(StatusCode::BAD_REQUEST);let message =
"GW: Content-length header set but couldn't extract request body".to_string();
res.render(Text::Plain(&message));
info_for_open_observe.status_code = StatusCode::BAD_REQUEST.as_u16();
info_for_open_observe.error = super::tracking::ErrorInfo{is_client_error:false,is_host_server_error:false,is_gateway_error:true,
message,};
info_for_open_observe.timing = super::tracking::TimingInfo{total_time_in_gateway: start_time.elapsed().as_millis(),total_time_host_server_answer_in_ms:None,};returncrate::gateway::tracking::ProxyResultVariants::SendToOpenObserve(
info_for_open_observe,);}};
request_to_destination_server_builder =
request_to_destination_server_builder.body(payload.clone());}// NOTE: Initialize struct to store durations
The text was updated successfully, but these errors were encountered:
Hi, I'm building an api gateway.
And inside my proxy method i have this code section. I want to know what is the right way of reading and sending in chunks instead of load all the body in memory. Could you help me, I wasn't able to find a method to load the body in chunks
The text was updated successfully, but these errors were encountered: