[erlang-questions] Patch to inets for correct handling of HTTP's Conditional GET

Frej Drejhammar frej.drejhammar@REDACTED
Sun Aug 19 20:38:38 CEST 2007


Hi,

The http client in inets for R11B-5 does not handle conditional get
correctly. Doing a http:request/4 with the "If-None-Match" and
"If-Modified-Since" headers set such that the server gives a 304 "Not
Modified" reply, the httpc_handler still expects to receive a
body. This eventually leads to a timeout. The attached bug.erl
demonstrates the problem by retrieving the slashdot rss-feed.

The included patch seems to fix the problem, although I'm not
completely sure about its correctness when pipelining is used.

Regards,

Frej Drejhammar

--- otp_src_R11B-5/lib/inets/src/http_client/httpc_handler.erl  2007-06-11 12:25:27.000000000 +0200
+++ otp_src_R11B-5.orig/lib/inets/src/http_client/httpc_handler.erl   2007-08-19 18:09:16.000000000 +0200
@@ -489,6 +489,9 @@
     {NewBody, NewRequest}= stream(Body, State#state.request, Code),
     handle_response(State#state{body = NewBody, request = NewRequest}).
 
+handle_http_body(<<>>, State = #state{status_line = {_,304, _}}) ->
+    handle_response(State#state{body = <<>>});
+
 handle_http_body(<<>>, State = #state{request = #request{method = head}}) ->
     handle_response(State#state{body = <<>>});

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.erl
Type: application/octet-stream
Size: 1138 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070819/4ac4f1f9/attachment.obj>


More information about the erlang-questions mailing list