I am trying to do a HTTPS post with scala and the Dispatch library. I can't find where to mark my connection as being https not http. Here is the code I have so far
println("Running Test")
val http = new Http
val req = :/("www.example.com" , 443) / "full/path.asp"
var response: NodeSeq = Text("")
http(req << "username=x&password=y" <> {response = _ } )
response
println("Done Running Test")
EDIT
So After attempting to figure this out I开发者_如何转开发 traced down what was needed the http line needs to look like this
http(req.secure << "username=x&password=y" <> {response = _ } )
Also In this specific instance I needed to POST as application/x-www-form-urlencoded that required the line to look like this
http(req.secure << ("username=x&password=y","application/x-www-form-urlencoded") <> {response = _ } )
This will now replace 40 Lines of C++ + Boost + Asio code.
So After attempting to figure this out I traced down what was needed the http line needs to look like this
http(req.secure << "username=x&password=y" <> {response = _ } )
Also In this specific instance I needed to POST as application/x-www-form-urlencoded that required the line to look like this
http(req.secure << ("username=x&password=y","application/x-www-form-urlencoded") <> {response = _ }
You could apply "secure" to the :/ factory:
:/("host").secure
精彩评论