isapir
isapir

Reputation: 23513

Can a response to an http request error be gziped?

When trying to execute an http request that causes a 400 Bad Request error, an nginx server returns the "400 Bad Request", a Content-Encoding: gzip, and the response in a non-encoded format.

So because of the Content-Encoding: gzip my code wraps the response with a GZIPInputStream which throws an error.

My question is: is gzip a valid encoding when the status code is not "200 OK"? if not, I can simply check for the status code and not try to gzip if anything other than 200 was returned.

Are there rules/guidelines about this? Is this documented anywhere?

TIA

Upvotes: 3

Views: 548

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42025

Yes, it is a valid encoding. Content-Encoding (and Transfer-Encoding) are orthogonal to status codes.

Upvotes: 4

Related Questions