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.

1
  • +1 for affirming that HTTP REQUESTS also support Transfer-Encoding, what a PITA. Commented Dec 22, 2011 at 9:07

6 Answers 6

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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.

Comments

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.

Comments

0

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

1 Comment

That seems to be the best choice.
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.

Comments

-1

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

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.