使用 Scala 和 Dispatch 进行 HTTPS POST
我正在尝试使用 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")
编辑
所以在尝试弄清楚这一点之后,我追踪到了所需的内容,http行需要看起来像这样
http(req.secure << "username=x&password=y" <> {response = _ } )
另外在这个特定的实例中,我需要以 application/x 的形式发布-www-form-urlencoded 要求该行看起来像这样
http(req.secure << ("username=x&password=y","application/x-www-form-urlencoded") <> {response = _ } )
这现在将替换 40 行 C++ + Boost + Asio 代码。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,在尝试弄清楚这一点之后,我追踪到了需要什么,http行需要看起来像这样
另外,在这个特定的实例中,我需要以 application/x-www-form-urlencoded 的形式发布,要求该行看起来像这样
So After attempting to figure this out I traced down what was needed the http line needs to look like this
Also In this specific instance I needed to POST as application/x-www-form-urlencoded that required the line to look like this
您可以将“secure”应用于 :/ 工厂:
You could apply "secure" to the :/ factory: