Reputation: 2937
I'm using Ocaml CURL to make http request to a server. I try to send it using the method post and I found this function (https://gist.github.com/zbroyar/1432555) :
let post ?(content_type = "text/html") url data =
let r,c = init_conn url in
Curl.set_post c true;
Curl.set_httpheader c [ "Content-Type: " ^ content_type ];
Curl.set_postfields c data;
Curl.set_postfieldsize c (String.length data);
Curl.perform c;
let rc = Curl.get_responsecode c in
Curl.cleanup c;
rc, (Buffer.contents r)
I understand that the value data contains the post values but in which form ? It should be "login=foo pass=bar" or "login=foo, pass=bar" ? Anyone has an idea ?
Upvotes: 0
Views: 293
Reputation: 6379
This is a POST request, it can send any kind of data using any form, that's why there is a Content-Type
header to tell the server how to decode the data.
By default, this function will send HTML, if you want to use the form encoding, replace "text/html"
with "application/x-www-form-urlencoded"
.
Upvotes: 1