scala - Sending a custom POST https request in dispatch (+cookies, + headers) -
there documentation sending post request in dispatch http://dispatch.databinder.net/combined+pages.html yet it's not clear. myrequest , mypost there?
i want send https post request + add cookies manually via headers + add customs headers form data, etc, , read response reading headers , cookies.
i know how prepare url sending post request:
val url = host(myurl + "?check=1&val1=123").secure what do next?
dispatch built on top of async http client. therefore, myrequest in example:
val myrequest = url("http://example.com/some/path") is com.ning.http.client.requestbuilder.
calling post method on requestbuilder turns request post request. that's what's happening in mypost example:
def mypost = myrequest.post i find dispatch documentation difficult follow. quick overview of various dispatch operators, see: periodic table of dispatch operators
if you're asking how build post request , add custom form parameters, want use <<(values) operator this:
val params = map("param1" -> "val1", "param2" -> "val2") val req = url("http://www.example.com/some/path" <<(params) likewise if want add custom headers can use <:<(map) operator this:
val headers = map("x-custom1" -> "val1", "x-custom2" -> "val2") val req = url("http://www.example.com/some/path" <<(params) <:<(headers) update: actually, there no post method on requestbuilder. call post part of dispatch , calls setmethod on underlying requestbuilder. see dispatch.methodverbs more details.
Comments
Post a Comment