How to print an http request using Dispatch and Scala

When I use the Dispatch and Scala library, for debugging purposes, how to print the entire HTTP request with headers, etc. in the text after writing a statement like this?

val svc = url("http://api.hostip.info/country.php")
+4
source share
2 answers

Assuming you're using the latest version of lib, url(...)returns Req, which is just a thin shell around com.ning.http.client.RequestBuilder. You can get the base request object with svc.toRequest, which you can then call toStringor combine other available methods depending on what information you are actually using. Additional Information:

Java doc for Request

+2

Netty.io, sl4j. :

com.ning.http.client

, LOT . , ch.qos.logback :

src/main/resources, default.logback.xml :

<configuration>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
  </appender>

  <root level="DEBUG">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>
+8

All Articles