6

the HTTP specification states that the Transfer-Encoding header is allowed for requests - but what error code should a server respond if it doesn't understand that given Transfer-Encoding.

As far as I know the HTTP standard doesn't cover this possibility, but maybe I have just overlooked it.

bignose
  • 30,281
  • 14
  • 77
  • 110
Fionn
  • 10,975
  • 11
  • 54
  • 84

6 Answers6

5

An unknown transfer-encoding should raise a HTTP error 501 "NOT IMPLEMENTED". That's what Apache does, at least.

Also see http://argray.com/unixfaq/httpd_error_codes.shtml

Edit: pointer to the corresponding RFC section: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2

ChristopheD
  • 112,638
  • 29
  • 165
  • 179
  • the description for 501 says: "The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource." So that doesn't seem to be a good choice. – Julian Reschke Mar 30 '09 at 11:50
4

I agree that the answer to this is non-obvious, and have followed up on the HTTP WG's mailing list.

UPDATE: Björn H. rightfully points out:

Section 3.6 of RFC 2616:

A server which receives an entity-body with a transfer-coding it does not understand SHOULD return 501 (Unimplemented), and close the
connection.

So it does address this already.

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

Mostly a personal opinion.

i always thought 5xx errors were actual programming errors, like something fell over. If a server doesnt understand the request i would say a 4xx error is a better response as the problem is with the request not so a failed process on the server. Im not sure which 4xx but there are a few so selecting one should not be hard.

mP.
  • 18,002
  • 10
  • 71
  • 105
0

Arguably failing to understand chunked encoding ought to be a 500 Internal Server Error rather than 501, because RFC-2616 says the server MUST understand it.

However, if a server chooses not to accept requests with chunked bodies, and it wants to blame the client for this, one way to do so legally would be 411 Length Required -- since one must not use Content-Length and Transfer-Encoding at the same time, and it is not practical to send a request without either anyway.

hmakholm left over Monica
  • 23,074
  • 3
  • 51
  • 73
0

A request with an invalid Transfer-Encoding for the HTTP version is malformed. Therefore, the server should respond with 400 Bad Request.

Ferdinand Beyer
  • 64,979
  • 15
  • 154
  • 145
-1

The RFC is a bit unclear, but IMHO it should be 406 Not Acceptable.

mjy
  • 2,727
  • 2
  • 20
  • 22
  • In my understanding of the RFC, code 406 should only be used if the server cannot deliver content that matches the request's "Accept" header. This is not the case here. – Ferdinand Beyer Mar 28 '09 at 15:14