[erlang-questions] Bug in Inets handling of PUT?

Tobias Löfgren ugglan@REDACTED
Wed Oct 18 12:19:44 CEST 2006


I've had this problem aswell, as Ingela said elsewhere the fix is coming in
the next release of erlang. Until then you can use this version of
whole_body in httpc_response.erl:

whole_body(Body, Length) ->
   case size(Body) of
       N when N < Length, N > 0 ->
           {?MODULE, whole_body, [Body, Length]};
       %% OBS!  The Server may close the connection to indicate that the
       %% whole body is now sent instead of sending an lengh
       %% indicator.In this case the lengh indicator will be
       %% 0 but N > 0 and we want to match the last branch in
       %% this function as the connection is not yet closed.
       N when N >= Length, Length > 0 ->
           %% Potential trailing garbage will be thrown away in
           %% format_response/1 Some servers may send a 100-continue
           %% response without the client requesting it through an
           %% expect header in this case the trailing bytes may be
           %% part of the real response message.
           {ok, Body};
       0 when 0 == Length -> %% The body is empty
           {ok, Body};
       _ ->
           {?MODULE, whole_body, [Body, Length]}
   end.

/tobias


On 10/18/06, Brad Marshall <brad@REDACTED> wrote:
>
> I'm calling a web service with a PUT via http:request/6.  The PUT results
> in
> a 200 and a content length of zero.  The zero-length response seems to be
> causing the request to hang until the keepalive timeout expires and the
> socket closes.  If I make the change below then the PUT works perfectly:
>
> diff httpc_response.erl httpc_response.erl.original
> 61c61
> <       N when N >= Length ->
> ---
> >       N when N >= Length, Length > 0 ->
>
> I'm new to Erlang so please point me in the right direction if I'm off
> base.
> I've checked the RFC and it seems valid for a PUT to have a zero-length
> response.  Oh, and I tried this in ibrowse and it worked perfectly, but
> I'd
> much rather use a built-in if possible.
>
> Any tips on solving this are greatly appreciated.
>
> Thanks,
> brad
>
> ________________________________________________
> Message sent using UebiMiau 2.7.9
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061018/d20e9fd1/attachment.htm>


More information about the erlang-questions mailing list