Thursday, 15 August 2013

http - Send HttpRequest using post method with Ocaml Curl -


I'm using Okem curl to request http from a server; I use the method to send it to post I try and I found this function ():

  post? (Content_type = "text / html") url data = r, c = init_conn url Curl.set_post c; Curl.set_httpheader c ["content-type:" ^ content_type]; Curl.set_postfields c data; Curl.set_postfieldsize c (String.length data); Curl Paramorma C; Let's go to rc = curl.c cURL.get_responsecode c; Cclean c; RC, (buffer content r)  

I understand that value data contains values ​​of the post but in what form? Should it be "login = foo pass = bar" or "login = foo, pass = bar"? Anyone have an idea?

This is a POST request, it can send any type of data using any type Therefore, to specify the server to decode the data, there is a content-type header, by default, this function will send the HTML, if you want to use it, then "text Replace / html "with " application / x-www-form-urlencoded ".


No comments:

Post a Comment