Re: How to determine server's decoding capability before sending entity?

On 15/02/2013 8:10 p.m., Yi, EungJun wrote:
> Hi, all.
>
> Before sending a POST request to HTTP/1.1 server, whose body is 
> encoded in the coding defined by Content-Encoding header, how do I 
> know the server's capability to decode the request's body?
>
> HEAD method seems to be only for GET method, and response for OPTIONS 
> request may not return any information about that.
>
> It is the only way that receive 415 Unsupported media type after 
> sending the request with the body?
>
> Thanks in advance.

There is one way allowed by HTTP/1.1 using a POST with 
Transfer-Encoding:chunked, and also Expect:100-continue.

The server will see the intended encoding type and reject it with 415 or 
accept it with a 100 (timeout is also needed).
After a 415 you can abort with an empty chunk and re-try with another 
encoding. After a 100 or a timeout you go ahead and deliver it.
** the timeout is needed due to HTTP/1.0 software erasing the 100 status 
code. In which case the best thing to do is deliver the expected body 
and handle any 415 which may still arrive.

Amos

Received on Friday, 15 February 2013 08:42:03 UTC