http.async.client打印标头

时间:2016-08-19 18:47:08

标签: http logging clojure

我在Clojure中使用[http.async.client "1.0.1"]作为HTTP客户端。它打印出我的请求和答案的调试消息(我不介意)和HTTP标题(我记得)。

以下是典型输出:

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]

如何停用该功能?

1 个答案:

答案 0 :(得分:0)

您的调试输出来自following line in com.ning.http.client.providers.netty.handler.HttpProtocol.handleHttpResponse

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

在当前形式中,您无法更改调试消息的内容。

相反,您可以编写自己的日志记录逻辑。您将请求参数传递给客户端函数,并返回一个响应映射,其中还包含所有相关的响应数据。您可以编写一个函数来检查您感兴趣的部件,并以您喜欢的任何格式记录它们。 http.async.client docs contain all the relevant information.

相关问题