-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downstream compression does not work for custom response #206
Comments
You are right. The compression module in the proxy logic needs some rework to take care of this case. |
At the moment this can be achieved by calling session.downstream_compression.adjust_level(3);
session
.downstream_compression
.request_filter(session.downstream_session.req_header());
let mut task = HttpTask::Header(Box::new(header), false);
session.downstream_compression.response_filter(&mut task);
if let HttpTask::Header(header, _) = task {
session.write_response_header(header).await?;
} else {
panic!("Unexpected: compression response filter replaced header task by {task:?}");
}
let mut task = HttpTask::Body(Some(self.body), true);
session.downstream_compression.response_filter(&mut task);
if let HttpTask::Body(Some(bytes), _) = task {
session.write_response_body(bytes).await?;
}
return Ok(true); If the response body consists of multiple chunks, All in all, not really trivial. But it works. |
This should have been fixed with 11863d2. These should behave as expected in the original issue post if the module is set up. Please let us know if this did not solve your issue. |
@gumpt: It looks like you forgot to adjust |
@gumpt I’ve created a branch, adjusting my code to these changes. It’s a huge change, but things are mostly working now. As far as I can tell, compression works correctly as well with the bulk of my work-around removed. Well, except for |
What is the problem your feature solves, or the need it fulfills?
I make a custom response in
request_filter
like this:But the response body is not compressed. Does compression only take effect for response from upstream?
Describe the solution you'd like
I want downstream compression to take effect for all responses to downstream.
The text was updated successfully, but these errors were encountered: