Setting User-Agent Header in Scala with Databinders Dispatch Library

血红的双手。 提交于 2019-12-07 02:15:37

问题


Does anyone know how to do this?


回答1:


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)") 



回答2:


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?




回答3:


This will work as well:

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


来源:https://stackoverflow.com/questions/1394667/setting-user-agent-header-in-scala-with-databinders-dispatch-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!