Archive

Posts Tagged ‘request’

How to make http post

February 24th, 2009

Erlang Documentation for http:request/4 does have the function description but it lacks of concrete example for making http post. Here we go:

Make sure inets is started

1> inets:start().
ok
2> http:request(post, {
2> "http://www.google.com/",
2> [], 
2> "application/x-www-form-urlencoded",
2> "hl=en&q=erlang&btnG=Google+Search&meta="
2> },
2> [], []).
{ok,{{"HTTP/1.1",405,"Method Not Allowed"},
     [{"date","Tue, 24 Feb 2009 15:43:25 GMT"},
      {"server","gws"},
      {"content-length","1391"},
      {"content-type","text/html; charset=UTF-8"}],
...

You may notice that the content_type is application/x-www-form-urlencoded

Networking , , , ,