dkh*_*nry 5 https scala scala-dispatch
我正在尝试使用scala和Dispatch库进行HTTPS发布.我找不到将我的连接标记为https而不是http的位置.这是我到目前为止的代码
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")
Run Code Online (Sandbox Code Playgroud)
编辑
因此,在尝试解决这个问题之后,我追溯了http线需要看起来像什么
http(req.secure << "username=x&password=y" <> {response = _ } )
Run Code Online (Sandbox Code Playgroud)
另外在这个特定的例子中,我需要POST作为application/x-www-form-urlencoded,要求行看起来像这样
http(req.secure << ("username=x&password=y","application/x-www-form-urlencoded") <> {response = _ } )
Run Code Online (Sandbox Code Playgroud)
这将取代40行C++ + Boost + Asio代码.
因此,在尝试弄清楚这一点之后,我追踪到了所需的内容,http 行需要如下所示
http(req.secure << "username=x&password=y" <> {response = _ } )
Run Code Online (Sandbox Code Playgroud)
另外,在这个特定的实例中,我需要以 application/x-www-form-urlencoded 的形式发布,要求该行看起来像这样
http(req.secure << ("username=x&password=y","application/x-www-form-urlencoded") <> {response = _ }
Run Code Online (Sandbox Code Playgroud)