Setting User-Agent Header in Scala with Databinders Dispatch Library

随声附和 提交于 2019-12-05 06:54:37

You need to append your request with the header info, using the <:< operator. Like this :

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

Just from reading the source, it looks like you're supposed to call http.client.params.setParameter("User-Agent","Cowbells") on your Http object. Have you tried this?

This will work as well:

url("http://example.com").addHeader("User-Agent", "Mozilla...")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!