Jump to content

HTTP: Difference between revisions

Line 4:
 
=={{header|Erlang}}==
===Synchronous===
-module(main).
-export([main/1]).
Line 12 ⟶ 13:
{ok, {_V, _H, Body}} -> io:fwrite("~p~n",[Body]);
{error, Res} -> io:fwrite("~p~n", Res)
end.
 
===Asynchronous===
 
-module(main).
-export([main/1]).
main([Url|[]]) ->
inets:start(),
http:request(get, {Url, [] }, [], [{sync, false}]),
receive
{http, {_ReqId, Res}} -> io:fwrite("~p~n",[Res]);
_Any -> io:fwrite("Error: ~p~n",[_Any])
after 10000 -> io:fwrite("Timed out.~n",[])
end.
 
418

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.