nboon nboon - 3 months ago 32
HTTP Question

http.async.client prints headers

I'm using

[http.async.client "1.0.1"]
as an HTTP client in Clojure. It prints both debug messages (which I don't mind) and the HTTP headers (which I do mind) of my request I make and the answer.

Here is a typical output:

16-08-19 18:37:36 Nilss-Air.fritz.box DEBUG [com.ning.http.client.providers.netty.request.NettyConnectListener:68] - Using non-cached Channel [id: 0x044195db, /192.168.178.22:52009 => google.com/172.217.20.110:80] for GET '/'
16-08-19 18:37:36 Nilss-Air.fritz.box DEBUG [com.ning.http.client.providers.netty.handler.HttpProtocol:409] -

Request DefaultHttpRequest(chunked: false)
GET / HTTP/1.1
Connection: keep-alive
Host: google.com
Accept: */*
User-Agent: http.async.client

Response DefaultHttpResponse(chunked: false)
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.de/?gfe_rd=cr&ei=8FG3V8nHAuag8weWr5DYCg
Content-Length: 258
Date: Fri, 19 Aug 2016 18:37:36 GMT

16-08-19 18:37:36 Nilss-Air.fritz.box DEBUG [com.ning.http.client.providers.netty.channel.ChannelManager:297] - Adding key: http://google.com:80 for channel [id: 0x044195db, /192.168.178.22:52009 => google.com/172.217.20.110:80]


How do I deactivate that?

Answer

Your debug output comes from the following line in com.ning.http.client.providers.netty.handler.HttpProtocol.handleHttpResponse:

logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response);

In its current form you cannot change the contents of the debug message.

Instead you can write your own logging logic. You pass your request parameters to the client functions and it returns a response map which contain also all the relevant response data. You can just write a function which will inspect parts you are interested in and log them in whatever format you like. http.async.client docs contain all the relevant information.

Comments