Skip to content
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

304 Not Modified response includes body #341

Closed
phooijenga opened this issue Nov 22, 2023 · 3 comments · Fixed by #342
Closed

304 Not Modified response includes body #341

phooijenga opened this issue Nov 22, 2023 · 3 comments · Fixed by #342
Labels
bug Something isn't working

Comments

@phooijenga
Copy link

Describe the bug

After adding Unleash to one of our Go projects we noticed a stream of log messages like these:

2023/11/22 12:07:53 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>
2023/11/22 12:08:08 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>
2023/11/22 12:08:23 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>
2023/11/22 12:08:38 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>
2023/11/22 12:08:53 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>
2023/11/22 12:09:08 Unsolicited response received on idle HTTP channel starting with "14\r\n\x1f\x8b\b\x00\x00\x00\x00\x00\x04\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n0\r\n\r\n"; err=<nil>

After some further investigation we found that the 304 Not Modified responses from Unleash Edge include a chunked and compressed response body (the 14... and further).

RFC 9110 § 15.4.5 says:

A 304 response is terminated by the end of the header section; it cannot contain content or trailers.

Steps to reproduce the bug

  1. Connect to Unleash Edge using unleash-client-go

Expected behavior

No response

Logs, error output, etc.

No response

Screenshots

image

Additional context

No response

Unleash version

v5.6.7, Edge v16.0.3, Go Client v4.3.1

Subscription type

None

Hosting type

None

SDK information (language and version)

No response

@phooijenga phooijenga added the bug Something isn't working label Nov 22, 2023
@phooijenga
Copy link
Author

It looks like this is caused by the Compress middleware compressing the empty response generated by the Etag middleware.

@kwasniew
Copy link

Thanks for the report. It is spot on and we were able to reproduce it with Go SDK. You're right that the order of middleware fns matters. We can't just swap the order of Etag and Compress since it introduces another bug.
We'll start looking into possible solutions soon.

chriswk added a commit that referenced this issue Nov 23, 2023
This includes the fix for returning a NoneBody rather than a Sized(0)
body, allowing the Compress middleware to just not process our response.

Thanks to @phooijenga for the PR on
https://github.com/chriswk/actix-middleware-etag

Fixes: #341
@chriswk
Copy link
Member

chriswk commented Nov 23, 2023

Since @phooijenga was so kind as to make a PR with the fix against our ETag middleware, I've made a new release with that fix, and a PR is in the works #342

chriswk pushed a commit that referenced this issue Nov 23, 2023
This includes the fix for returning a NoneBody rather than a Sized(0)
body, allowing the Compress middleware to just not process our response.

Thanks to @phooijenga for the PR on
https://github.com/chriswk/actix-middleware-etag

Fixes: #341
@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants