Skip to content

Commit

Permalink
Fixed Session::write_response_header_ref bypassing downstream modules
Browse files Browse the repository at this point in the history
  • Loading branch information
palant committed Jun 15, 2024
1 parent 31d7b63 commit e087175
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pingora-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ impl Session {
self.downstream_session.write_response_header(resp).await
}

/// Similar to `write_response_header()`, this fn will clone the `resp` internally
pub async fn write_response_header_ref(
&mut self,
resp: &ResponseHeader,
end_of_stream: bool,
) -> Result<(), Box<Error>> {
self.write_response_header(Box::new(resp.clone()), end_of_stream).await
}

/// Write the given HTTP response body chunk to the downstream
///
/// Different from directly calling [HttpSession::write_response_body], this function also
Expand Down Expand Up @@ -514,7 +523,7 @@ impl<SV> HttpProxy<SV> {
// The hook can choose to write its own response, but if it doesn't, we respond
// with a generic 502
if session.response_written().is_none() {
match session.write_response_header_ref(&BAD_GATEWAY).await {
match session.write_response_header_ref(&BAD_GATEWAY, true).await {
Ok(()) => {}
Err(e) => {
self.handle_error(
Expand Down

0 comments on commit e087175

Please sign in to comment.