如何在使用Dispatch和Scala时打印http请求
当我使用Dispatch库和Scala时,出于调试目的,如何在写完这样的语句之后用文本中的标题等打印出整个HTTP请求?
When I am using Dispatch library and Scala, for debugging purpose, how to print out the entire HTTP request with headers, etc. in text after writing a statement like this ?
val svc = url("http://api.hostip.info/country.php")
假设您使用的是最新版本的lib, url(...)
返回 Req
,这只是 com.ning.http的一个薄包装器.client.RequestBuilder
。您可以使用 svc.toRequest
获取基础请求对象,然后可以调用 toString
或组合其他方法取决于您真正追求的信息。更多信息:
Assuming you're using the latest version of the lib, url(...)
returns a Req
, which is just a thin wrapper around com.ning.http.client.RequestBuilder
. You can get the underlying request object with svc.toRequest
, which you can then call toString
on or combine the other methods available depending on what information you're really after. More info: