Scala http操作 [英] Scala http operations
本文介绍了Scala http操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Scala中执行以下操作:
How do I perform the following in Scala:
- HTTP获取
- HTTP获取自定义标题
- HTTP帖子
推荐答案
你可以试用发货。起初有点难以掌握,但过了一段时间我才开始喜欢它。它适用于HttpClient。
You could try out Dispatch. A little difficult to grasp at first, but after a while I've started to like it. It works on top of HttpClient.
import dispatch.Http
import Http._
// Get
Http(url("http://youruri.com/yo") >>> System.out)
// Get with header
Http(url("http://youruri.com/yo") <:< Map("Accept" -> "application/json") >>> System.out)
// Post
Http(url("http://youruri.com/yo") << yourPostData >|)
这篇关于Scala http操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文