5

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.

Urist McDev
  • 498
  • 3
  • 14
dkhenry
  • 257
  • 4
  • 11

2 Answers2

3

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 = _ } 
dkhenry
  • 257
  • 4
  • 11
1

You could apply "secure" to the :/ factory:

:/("host").secure
Brett
  • 5,690
  • 6
  • 36
  • 63