Using inets http client
Will Newton
will@REDACTED
Sat Jun 4 19:30:44 CEST 2005
Following the documentation of the inets http client I have written this code:
http_wait_with_timeout(RequestId, Timeout) ->
if
Timeout > 0 ->
receive
{http, {RequestId, Result}} ->
Result;
{http, {RequestId, {error, Reason}}} ->
throw({error, Reason})
after
1000 ->
io:format(".")
end,
http_wait_with_timeout(RequestId, Timeout - 1000);
true ->
throw({timeout})
end.
get_url(Url) ->
application:start(inets),
case http:request(get, {Url, []}, [], [{sync, false}]) of
{ok, RequestId} ->
http_wait_with_timeout(RequestId, 15000);
_ ->
io:format("http request failed~n")
end.
I get a series of periods printed but I never get the expected response from
the async http request. Can anyone tell me what am I doing wrong?
Thanks,
More information about the erlang-questions
mailing list