-
Notifications
You must be signed in to change notification settings - Fork 39
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
Response is not getting compressed or being corrupted? #61
Comments
don't set the content encoding urself. |
Thanks, @jonathanong for your time. Well, without setting content encoding myself, I stop getting errors. But I believe it's not getting compressed when I don't set content encoding. Because in such case when I hit the URL using curl I simply get the plain text saying 'Hello World'. If curl doesn't support decompression by default, how am I receiving a plain text then? |
if can you make a PR with a failing test case? |
sorry for being a noob, but what's PR? do you mean sample programs? |
pull request |
Thank you @jonathanong for your comments. I just retested the whole process once again and I realised that my code was already working. I was making mistakes in assuming that response should always be compressed. But what I realised now, after lots of research is that compression works only when the client sends a header with Edit: And you were also right that if |
this is my middleware code
app.use(compress({ filter: function (content_type) { return /text/i.test(content_type) }, threshold: 1, flush: require('zlib').Z_SYNC_FLUSH }))
And this is my response code
now when I hit the url localhost:3000/test, I get the error saying
But when I hit same url using CURL, I get the text saying
I guess it's apparent that data is not getting compressed otherwise curl wouldn't have shown plain text. And I think Chrome error is due to content-encoding being gzip but actual data being plain text. May be I'm wrong but this is sure that there is some problem is my code otherwise chrome should have shown Hello World without error, isn't?
The text was updated successfully, but these errors were encountered: