We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When accept-encoding is gzip, we need to set the content-type to text/plain.
accept-encoding
gzip
content-type
text/plain
this.response.set('Content-Encoding', 'gzip'); this.response.body = yield gzip('hello world');
The above code would fail the test because, when content-enconding is gzip, the default content-type is application/octet-stream.
content-enconding
application/octet-stream
Adding the content-type assignment would solve the problem.
this.response.set('Content-Encoding', 'gzip'); this.response.set('content-type', 'text/plain'); this.response.body = yield gzip('hello world');
Here is one solution in case anyone need.
app.use(function* () { const ae = this.request.acceptsEncodings('gzip', 'identity'); switch (ae) { case 'gzip': this.response.set('Content-Encoding', 'gzip'); this.response.set('content-type', 'text/plain'); this.response.body = yield gzip('hello world'); break; case 'identity': this.response.set('Content-Encoding', 'identity'); this.response.body = 'hello world'; break; default: break; } });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When
accept-encoding
isgzip
, we need to set thecontent-type
totext/plain
.The above code would fail the test because, when
content-enconding
isgzip
, the defaultcontent-type
isapplication/octet-stream
.Adding the
content-type
assignment would solve the problem.It takes me a lot time to understand what this chapter is focusing on.
Here is one solution in case anyone need.
The text was updated successfully, but these errors were encountered: