on master help sign in
Merge pull request #698 from ChickenProp/log-real-requests

Warp: Log real requests when app throws an error.

commit89f81ce1dbfe7eea82f2e3a6c892bcbff65ca33b authorMichael Snoyman <michael@snoyman.com> dateSun 15 Jul 2018, 06:08 (8 years ago) parenteb298a870f091a
3 files changed+11−6
warp/ChangeLog.md+5 warp/Network/Wai/Handler/Warp/Run.hs+5−5 warp/warp.cabal+1−1
warp/ChangeLog.md+5
@@ -1,3 +1,8 @@
1+## 3.2.23
2+
3+* Log real requsts when an app throws an error.
4+ [#698](https://github.com/yesodweb/wai/pull/698)
5+
16## 3.2.22
27
38* Fixing large request body in HTTP/2.
warp/Network/Wai/Handler/Warp/Run.hs+5−5
@@ -339,8 +339,9 @@ serveConnection conn ii1 origAddr transport settings app = do
339339 -- https://github.com/yesodweb/wai/issues/618
340340 Just NoKeepAliveRequest -> return ()
341341 Nothing -> do
342− sendErrorResponse addr istatus e
342+ sendErrorResponse (dummyreq addr) istatus e
343343 throwIO e
344+
344345 where
345346 getProxyProtocolAddr src =
346347 case settingsProxyProtocol settings of
@@ -388,12 +389,11 @@ serveConnection conn ii1 origAddr transport settings app = do
388389 | Just ConnectionClosedByPeer <- fromException se = False
389390 | otherwise = True
390391
391− sendErrorResponse addr istatus e = do
392+ sendErrorResponse req istatus e = do
392393 status <- readIORef istatus
393394 when (shouldSendErrorResponse e && status) $ do
394395 let ii = toInternalInfo ii1 0 -- dummy
395− dreq = dummyreq addr
396− void $ sendResponse settings conn ii dreq defaultIndexRequestHeader (return S.empty) (errorResponse e)
396+ void $ sendResponse settings conn ii req defaultIndexRequestHeader (return S.empty) (errorResponse e)
397397
398398 dummyreq addr = defaultRequest { remoteHost = addr }
399399
@@ -405,7 +405,7 @@ serveConnection conn ii1 origAddr transport settings app = do
405405 keepAlive <- processRequest istatus src req mremainingRef idxhdr nextBodyFlush ii
406406 `E.catch` \e -> do
407407 -- Call the user-supplied exception handlers, passing the request.
408− sendErrorResponse addr istatus e
408+ sendErrorResponse req istatus e
409409 settingsOnException settings (Just req) e
410410 -- Don't throw the error again to prevent calling settingsOnException twice.
411411 return False
warp/warp.cabal+1−1
@@ -1,5 +1,5 @@
11Name: warp
2−Version: 3.2.22
2+Version: 3.2.23
33Synopsis: A fast, light-weight web server for WAI applications.
44License: MIT
55License-file: LICENSE