3

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

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
isapir
  • 21,295
  • 13
  • 115
  • 116
  • 2
    gzip is valid in any response code, but in any way you can make decigion using only status code(actually I don't know why you need content when status code is not 200) – ice Nov 13 '12 at 06:41
  • this is for a code library for other developers to use, so when possible we should give them as much information back as possible, including body of requests that result in an error. – isapir Nov 13 '12 at 21:28
  • 1
    @ice _"actually I don't know why you need content when status code is not 200"_ - because 301, 302, 303: _"the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s)."_, 403: _"If [...] the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity"_, ... – CodeCaster Nov 15 '12 at 10:33

1 Answers1

4

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

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98