http - Send HttpRequest using post method with Ocaml Curl -


i'm using ocaml curl make http request server. try send using method post , found 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 value data contains post values in form ? should "login=foo pass=bar" or "login=foo, pass=bar" ? has idea ?

this post request, can send kind of data using form, that's why there content-type header tell server how decode data. default, function send html, if want use form encoding, replace "text/html" "application/x-www-form-urlencoded".


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -