Skip to content

Commit

Permalink
chore: make function upstream_response_body_filter async
Browse files Browse the repository at this point in the history
  • Loading branch information
jdelgadoalfonso committed May 13, 2024
1 parent b6f6506 commit a261f98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions pingora-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,24 @@ impl<SV> HttpProxy<SV> {
}
}

fn upstream_filter(
async fn upstream_filter(
&self,
session: &mut Session,
task: &mut HttpTask,
ctx: &mut SV::CTX,
) -> Result<()>
where
SV: ProxyHttp,
SV: ProxyHttp + Send + Sync,
{
match task {
HttpTask::Header(header, _eos) => {
self.inner.upstream_response_filter(session, header, ctx)
}
HttpTask::Body(data, eos) => self
.inner
.upstream_response_body_filter(session, data, *eos, ctx),
HttpTask::Body(data, eos) => {
self.inner
.upstream_response_body_filter(session, data, *eos, ctx)
.await
}
HttpTask::Trailer(Some(trailers)) => self
.inner
.upstream_response_trailer_filter(session, trailers, ctx)?,
Expand Down
2 changes: 1 addition & 1 deletion pingora-proxy/src/proxy_h1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl<SV> HttpProxy<SV> {
{
// skip caching if already served from cache
if !from_cache {
self.upstream_filter(session, &mut task, ctx)?;
self.upstream_filter(session, &mut task, ctx).await?;

// cache the original response before any downstream transformation
// requests that bypassed cache still need to run filters to see if the response has become cacheable
Expand Down
2 changes: 1 addition & 1 deletion pingora-proxy/src/proxy_h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl<SV> HttpProxy<SV> {
SV::CTX: Send + Sync,
{
if !from_cache {
self.upstream_filter(session, &mut task, ctx)?;
self.upstream_filter(session, &mut task, ctx).await?;

// cache the original response before any downstream transformation
// requests that bypassed cache still need to run filters to see if the response has become cacheable
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 @@ -223,7 +223,7 @@ pub trait ProxyHttp {
///
/// This function will be called every time a piece of response body is received. The `body` is
/// **not the entire response body**.
fn upstream_response_body_filter(
async fn upstream_response_body_filter(
&self,
_session: &mut Session,
_body: &mut Option<Bytes>,
Expand Down

0 comments on commit a261f98

Please sign in to comment.