How to print the http request when using Dispatch and Scala


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

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:

Java doc for Request

Source for dispatch