Strange behavior of http:request/4
東村邦彦
ktoumura@REDACTED
Mon Feb 8 14:16:33 CET 2010
Hi
I just found strange behavior of http:request/4.
When I tried to retrieve a missing content with {sync, false} and
{stream, {self,once}} options, http:request/4 sent two messages like following.
{http,{#Ref<...>, stream, <<"<!DOCTYPE ...</HTML>\n">>}}
{http,{#Ref<...>,
{{"HTTP/1.1",404,"Not Found"},
[{"connection","Keep-Alive"}, ...}],
<<>>}}}
There is no "stream_start/end" message, but there is "stream" message.
And, in the second message, a body part is empty.
In the inets reference manual, it says that "stream: Streams the body of
a 200 or 206 response to the calling process or to a file".
So, I think it should return just one message like following
{http,{#Ref<...>,
{{"HTTP/1.1",404,"Not Found"},
[{"connection","Keep-Alive"}, ...}],
<<"<!DOCTYPE ...</HTML>\n">>}}}
(because it is impossible to return a status code when using "stream*" messages)
A console output is below.
------
$ erl
Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0]
[kernel-poll:false]
Eshell V5.7.4 (abort with ^G)
1> inets:start().
ok
2> http:request(get,{"http://www.erlang.org/no_such_file",[]},[],[{sync,false},{stream,{self,once}}]).
{ok,#Ref<0.0.0.68>}
3> flush().
Shell got {http,{#Ref<0.0.0.68>,stream,
<<"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
2.0//EN\">\n<HTML><HEAD>\n<TITLE>404 Not
Found</TITLE>\n</HEAD><BODY>\n<H1>Not Found</H1>\nThe requested URL
/no_such_file was not found on this
server.<P>\n<HR>\n<ADDRESS>Apache/1.3.29 Server at www.erlang.org Port
80</ADDRESS>\n</BODY></HTML>\n">>}}
Shell got {http,{#Ref<0.0.0.68>,
{{"HTTP/1.1",404,"Not Found"},
[{"connection","Keep-Alive"},
{"date","Mon, 08 Feb 2010 12:13:51 GMT"},
{"server","Apache"},
{"content-length","277"},
{"content-type","text/html; charset=iso-8859-1"},
{"keep-alive","timeout=35, max=99"}],
<<>>}}}
ok
------
--
Kunihiko Toumura
ktoumura@REDACTED
More information about the erlang-questions
mailing list