Tracing HTTP request/response using servant-client or http-client
Hi, I wonder if there is a possibility to make servant-client or the layer below, i.e. http-client log all requests and corresponding responses into a log file. There is `managerModifyRequest :: ManagerSettings <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:ManagerSettings> -> Request <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:Request> -> IO <https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO> Request <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:Request> ` ( https://github.com/snoyberg/http-client/blob/master/http-client/Network/HTTP...) which would allow to build logging for requests I suppose. However I could neither find a corresponding hook for Response, nor a "batteries included"TM `logRequests = True`, `requestLogger=...` or something along those lines. Best Jan
Hi, I just found `checkResponse :: Request -> Response BodyReader -> IO ()`. Unfortunately reading the body from it in order to log it will apparently empty the responseBody for further processors. Any ideas? Regards Jan P.S. I will probably open an issue on http-client Jan von Löwenstein <jan.loewenstein@gmail.com> schrieb am Di., 13. Dez. 2016 um 22:45 Uhr:
Hi,
I wonder if there is a possibility to make servant-client or the layer below, i.e. http-client log all requests and corresponding responses into a log file.
There is `managerModifyRequest :: ManagerSettings <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:ManagerSettings> -> Request <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:Request> -> IO <https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO> Request <https://hackage.haskell.org/package/http-client-0.5.4/docs/Network-HTTP-Client.html#t:Request> ` ( https://github.com/snoyberg/http-client/blob/master/http-client/Network/HTTP...) which would allow to build logging for requests I suppose.
However I could neither find a corresponding hook for Response, nor a "batteries included"TM `logRequests = True`, `requestLogger=...` or something along those lines.
Best Jan
participants (1)
-
Jan von Löwenstein