[Fwd: http client hell]
blaguehubert
blaguehubert@REDACTED
Wed Dec 8 15:23:48 CET 2004
I'm using inets shipped with Erlang/OTP10.
I tried your fixed version, but I have the same error with some websites.
Here is the full error message:
5> test:req("http://www.flipcode.com").
=ERROR REPORT==== 8-Dec-2004::14:15:33 ===
** Generic server <0.55.0> terminating
** Last message in was {tcp,#Port<0.134>,
<<72,84,84,80,47,49,46,49,32,50,48,48,32,79,75,13,10,68,97,116,101,58,32,87,101,100,44,32,48,56,32,68,101,99,32,50,48,48,52,32,49,53,58,48,51,58,51,57,32,71,77,84,13,10,83,101,114,118,101,114,58,32,65,112,97,99,104,101,47,49,46,51,46,50,55,32,40,85,110,105,120,41,32,32,40,82,101,100,45,72,97,116,47,76,105,110,117,120,41,32,109,111,100,95,115,115,108,47,50,46,56,46,49,50,32,79,112,101,110,83,83,76,47,48,46,57,46,54,98,32,68,65,86,47,49,46,48,46,51,32,80,72,80,47,52,46,49,46,50,32,109,111,100,95,112,101,114,108,47,49,46,50,54,13,10,67,111,110,110,101,99,116,105,111,110,58,32,99,108,111,115,101,13,10,84,114,97,110,115,102,101,114,45,69,110,99,111,100,105,110,103,58,32,99,104,117,110,107,101,100,13,10,67,111,110,116,101,110,116,45,84,121,112,101,58,32,116,101,120,116,47,104,116,109,108,13,10,13,10,102,101,55,13,10,60,104,116,109,108,62,10,60,104,101,97,100,62,60,116,105,116,108,101,62,102,108,105,112,99,111,100,101,32,45,32,68,101,118,101,108,111,112,109,101,110,116,32,78,101,119,115,60,47,116,105,116,108,101,62,10,60,115,116,121,108,101,32,116,121,112,101,61,34,116,101,120,116,47,99,115,115,34,62,10,10,10,97,46,109,101,110,117,108,105,110,107,58,108,105,110,107,32,32,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,108,105,110,107,32,32,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112
07,101,109,112,116,121,58,118,105,115,105,116,101,100,44,32,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,97,99,116,105,118,101,32,123,116,101,120,116,45,100,101,99,111,114,97,116,105,111,110,58,32,110,111,110,101,125,10,10,97,46,111,114,97,110,103,101,108,105,110,107,58,108,105,110,107,32,32,32,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,97,46,111,114,97,110,103,101,108,105,110,107,58,118,105,115,105,116,101,100,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,97,46,111,114,97,110,103,101,108,105,110,107,58,97,99,116,105,118,101,32,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,10,97,46,112,97,108,101,103,114,101,101,110,58,108,105,110,107,32,32,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,112,97,108,101,103,114,101,101,110,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,112,97,108,101,103,114,101,101,110,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,10,97,46,98,108,117,101,108,105,110,107,58,108,105,110,107,32,32,32,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,97,46,98,108,117,101,108,105,110,107,58,118,105,115,105,116,101,100,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,97,46,98,108,117,101,108,105,110,107,58,97,99,116,105,118,101,32,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,10,97,46,115,111,102>>}
** When Server state == {state,{request,
#Ref<0.0.0.261>,
<0.36.0>,
0,
http,
{"www.flipcode.com",80},
"/",
[],
get,
{http_request_h,
undefined,
"keep-alive",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
"www.flipcode.com",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
[],
undefined,
undefined,
undefined,
undefined,
"0",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
[]},
{[],[]},
{http_options,infinity,true,[],false,false}},
{tcp_session,
{{"www.flipcode.com",80},<0.55.0>},
false,
http,
#Port<0.134>,
1},
undefined,
undefined,
undefined,
{http_response,parse,[nolimit]},
{[],[]},
true,
[],
nolimit,
nolimit}
** Reason for termination ==
** {{badmatch,{noreply,{state,{request,
#Ref<0.0.0.261>,
<0.36.0>,
0,
http,
{"www.flipcode.com",80},
"/",
[],
get,
{http_request_h,
undefined,
"keep-alive",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
"www.flipcode.com",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
[],
undefined,
undefined,
undefined,
undefined,
"0",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
[]},
{[],[]},
{http_options,infinity,true,[],false,false}},
{tcp_session,
{{"www.flipcode.com",80},<0.55.0>},
false,
http,
#Port<0.134>,
1},
{"HTTP/1.1",200,"OK"},
{http_response_h,
undefined,
"close",
undefined,
undefined,
undefined,
"chunked",
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
"0",
undefined,
undefined,
undefined,
"text/html",
undefined,
undefined,
[{"date","Wed, 08 Dec 2004 15:03:39 GMT"},
{"server",
"Apache/1.3.27 (Unix)
(Red-Hat/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6b DAV/1.0.3 PHP/4.1.2
mod_perl/1.26"}]},
undefined,
{http_chunk,
decode_data,
[4071,
<<60,104,116,109,108,62,10,60,104,101,97,100,62,60,116,105,116,108,101,62,102,108,105,112,99,111,100,101,32,45,32,68,101,118,101,108,111,112,109,101,110,116,32,78,101,119,115,60,47,116,105,116,108,101,62,10,60,115,116,121,108,101,32,116,121,112,101,61,34,116,101,120,116,47,99,115,115,34,62,10,10,10,97,46,109,101,110,117,108,105,110,107,58,108,105,110,107,32,32,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,108,105,110,107,32,32,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,108,105,110,107,44,32,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,118,105,115,105,116,101,100,44,32,97,46,109,101,110,117,108,105,110,107,101,109,112,116,121,58,97,99,116,105,118,101,32,123,116,101,120,116,45,100,101,99,111,114,97,116,105,111,110,58,32,110,111,110,101,125,10,10,97,46,111,114,97,110,103,101,108,105,110,107,58,108,105,110,107,32,32,32,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,97,46,111,114,97,110,103,101,108,105,110,107,58,118,105,115,105,116,101,100,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,97,46,111,114,97,110,103,101,108,105,110,107,58,97,99,116,105,118,101,32,32,123,32,99,111,108,111,114,58,35,70,70,65,66,48,52,59,32,125,10,10,97,46,112,97,108,101,103,114,101,101,110,58,108,105,110,107,32,32,32,32,123,99,111,108,11
,103,114,101,101,110,58,118,105,115,105,116,101,100,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,97,46,112,97,108,101,103,114,101,101,110,58,97,99,116,105,118,101,32,32,123,99,111,108,111,114,58,32,35,98,57,102,102,100,48,59,32,125,10,10,97,46,98,108,117,101,108,105,110,107,58,108,105,110,107,32,32,32,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,97,46,98,108,117,101,108,105,110,107,58,118,105,115,105,116,101,100,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,97,46,98,108,117,101,108,105,110,107,58,97,99,116,105,118,101,32,32,123,32,99,111,108,111,114,58,35,48,51,70,48,70,70,59,32,125,10,10,97,46,115,111,102>>,
{nolimit,<<>>,4071,nolimit}]},
{[],[]},
true,
[],
nolimit,
nolimit}}},
[{httpc_handler,handle_http_body,2},
{gen_server,handle_msg,6},
{proc_lib,init_p,5}]}
Ingela Anderton wrote:
>blaguehubert wrote:
>
>
>>I'm trying to use the http:request function, but I randomly get this
>>
>>horrible message before it crash my program:
>>
>>*=ERROR REPORT==== 7-Dec-2004::23:39:22 ===
>>** Generic server <0.64.0> terminating
>>** Last message in was {tcp_closed,#Port<0.137>}
>>** When Server state == {state,{request,
>> #Ref<0.0.0.822>,
>> <0.114.0>,
>> 0,
>> http,
>> {"perso.efrei.fr",80},
>> "/~colombi//",
>> [],
>> get,
>> {http_request_h,
>> undefined,
>> "keep-alive",
>> undefined,
>> undefined,
>> undefined,
>> undefined,
>>
>>etc...
>>
>>
>You cut out the most interesting part e.i. the reason for the
>termination. That the tcp port was closed might be perfectly normal
>as many servers close the connection to indicate that the whole answer
>has been sent instead of sending a length indicator.
>Which version of intes are you using?
>
>
>
>>Here is my code :
>>*
>>req(Url) ->
>>case (catch req(Url,10)) of
>> {ok, Body} ->
>> {ok, Body};
>> _ ->
>> error
>> end.
>>
>>req(Url, NbTry) ->
>>{ok, RequestId} = http:request(get, {Url, []}, [], [{sync, false}]),
>>receive
>>{http, {RequestId, Result}} ->
>> {N, Header, Body} = Result,
>> {ok, binary_to_list(Body)}
>>after 60000 ->
>> if
>> NbTry) > 0 ->
>> req(Url, NbEssais-1);
>> true ->
>> error
>> end
>>end.
>>
>>Like you can see, I use catch statement and timeout because I thought it
>>was only an exception, but it seems more serious...
>>
>>
>
>I fixed your code above as it did not compile. And this is the result I get
>every time I try it with intes-4.0.1
>
>3> test:req("http://perso.efrei.fr:80/~colombi/").
>{ok,"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n <title>No title</title>\n <meta name=\"generator\" content=\"amaya 8.5, see http://www.w3.org/Amaya/\" />\n</head>\n\n<body>\n<p>un lien de test: <a href=\"./ici.html\">ici</a></p>\n</body>\n</html>\n"}
>
>Your code fixed:
>
>-module(test).
>
>-export([req/1]).
>
>req(Url) ->
> case (catch req(Url,10)) of
> {ok, Body} ->
> {ok, Body};
> _ ->
> error
> end.
>
>req(Url, NbTry) ->
> {ok, RequestId} = http:request(get, {Url, []}, [], [{sync, false}]),
> receive
> {http, {RequestId, Result}} ->
> {_N, _Header, Body} = Result,
> {ok, binary_to_list(Body)}
> after 60000 ->
> if
> NbTry > 0 ->
> req(Url, NbTry-1);
> true ->
> error
> end
>end.
>
>
>
More information about the erlang-questions
mailing list