Skip to content

Commit

Permalink
chore: make body response mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
jdelgadoalfonso committed Apr 30, 2024
1 parent 4e47ea0 commit 2cad1fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pingora-proxy/src/proxy_h1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ impl<SV> HttpProxy<SV> {

debug!("Sending header to upstream {:?}", req);

// TODO JADA: Tengo que conocer cuanto va a crecer/decrecer el body
// para modificar el Content-Length
match client_session.write_request_header(Box::new(req)).await {
Ok(_) => { /* Continue */ }
Err(e) => {
Expand All @@ -94,7 +96,6 @@ impl<SV> HttpProxy<SV> {

// start bi-directional streaming
let ret = if !session.is_body_empty() {
trace!("Estamos explorando un universo de posibilidades!!!");
tokio::try_join!(
self.proxy_handle_downstream_mid(session, tx_downstream, rx_upstream, ctx),
self.proxy_handle_upstream(client_session, tx_upstream, rx_downstream),
Expand Down Expand Up @@ -312,10 +313,10 @@ impl<SV> HttpProxy<SV> {
}
}

let buf = Some(buf.freeze());
let mut buf = Some(buf.freeze());
match self
.inner
.upstream_request_body_filter(session, &buf, ctx)
.upstream_request_body_filter(session, &mut buf, ctx)
.await
{
Ok(_) => { /* continue */ }
Expand All @@ -330,7 +331,7 @@ impl<SV> HttpProxy<SV> {

match send_permit {
Ok(send_permit) => {
send_body_to_pipe(buf.clone(), true, send_permit).await;
send_body_to_pipe(buf.take(), true, send_permit).await;
break;
}
Err(ref _e) => {
Expand Down
2 changes: 1 addition & 1 deletion pingora-proxy/src/proxy_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub trait ProxyHttp {
async fn upstream_request_body_filter(
&self,
_session: &mut Session,
_body: &Option<Bytes>,
_body: &mut Option<Bytes>,
_ctx: &mut Self::CTX,
) -> Result<()>
where
Expand Down

0 comments on commit 2cad1fd

Please sign in to comment.