Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  Bug in http client code (httpc_handler)

erik.ej.reitsma at ericss
Posted: Mon Oct 20, 2003 1:56 pm Reply with quote
Guest
Hi,

I have found what seems to me like a bug in httpc_handler in inets-3.0.7 (and also in inets-3.0.6). The problem is, that in some situation the body of an HTTP POST is sent twice.

When I do an HTTP POST to a .NET server, the .NET server responds with a 100-continue, whether I ask for it or not. In the documentation of httpc_handler:status_continue/2 it says, that this should be ignored if the request has already been completed. In my case, this is already completed, because the POST body is sent immediately if I do not specify that I wish to expect the 100-continue. Therefore the body gets sent twice: once at the initial request, and again when the .NET server sends the status code 100.

I have replaced the implementation of httpc_handler:status_continue/2 with the following code:

status_continue(Req,Session) ->
Headers = Req#request.headers,
Method = Req#request.method,
if
Method==post;Method==put ->
case Headers#req_headers.expect of
"100-continue" ->
%% only in this case we have not yet send the body
{_,Body}=Req#request.content,
http_lib:send(Session#tcp_session.scheme,Session#tcp_session.socket,Body),
next_response_with_request(Req,Session);
_ ->
%% in other cases the status code should be ignored
next_response_with_request(Req,Session)
end;
true ->
%% in other cases the status code should be ignored
next_response_with_request(Req,Session)
end.

This seems to me to be a more correct implementation of the comments in the original source of httpc_handler. It solves the problem I had and should not break anything.
For inets-3.0.6, #tcp_session should be replaced by #session.

*Erik.



Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum