使用Databinders Dispatch Library在Scala中设置User-Agent标头

时间:2009-09-08 15:30:41

标签: scala scala-dispatch

有谁知道怎么做?

3 个答案:

答案 0 :(得分:15)

您需要使用标题信息附加您的请求,使用<:<运营商。像这样:

url("http://example.com") <:< Map("User-Agent" -> "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)") 

答案 1 :(得分:3)

只是阅读源代码,看起来你应该在你的Http对象上调用http.client.params.setParameter(“User-Agent”,“Cowbells”)。你试过这个吗?

答案 2 :(得分:2)

This也可以使用:

url("http://example.com").addHeader("User-Agent", "Mozilla...")