views:

498

answers:

4

Hi,

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.

A: 

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

mjy
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
A: 

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

Ferdinand Beyer
That seems to be the best choice.
Julian Reschke
+4  A: 

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
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
+3  A: 

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