on master help sign in
fix test now that the request logger logs the body
commitc010a2826fc13b33b306a9d7dcd9db7ce56da660 authorGreg Weber <greg@gregweber.info> dateFri 16 Oct 2015, 13:13 (11 years ago) parent8137be3
2 files changed+5−5
wai-extra/Network/Wai/Middleware/RequestLogger.hs+4−2 wai-extra/test/WaiExtraSpec.hs+1−3
wai-extra/Network/Wai/Middleware/RequestLogger.hs+4−2
@@ -248,9 +248,11 @@ detailedMiddleware' :: Callback
248248 -> Middleware
249249detailedMiddleware' cb ansiColor ansiMethod ansiStatusCode app req sendResponse = do
250250 (req', body) <-
251− case requestBodyLength req of
251+ -- second tuple item should not be necessary, but a test runner might mess it up
252+ case (requestBodyLength req, contentLength (requestHeaders req)) of
252253 -- log the request body if it is small
253− KnownLength len | len <= 2048 -> getRequestBody req
254+ (KnownLength len, _) | len <= 2048 -> getRequestBody req
255+ (_, Just len) | len <= 2048 -> getRequestBody req
254256 _ -> return (req, [])
255257
256258 let reqbodylog _ = if null body then [""] else ansiColor White " Request Body: " <> body <> ["\n"]
wai-extra/test/WaiExtraSpec.hs+1−3
@@ -341,10 +341,8 @@ caseDebugRequestBody = do
341341 }
342342 where
343343 params = [("foo", "bar"), ("baz", "bin")]
344− -- FIXME change back once we include post parameter output in logging
345− -- postOutput = T.pack $ "POST \nAccept: \n Params: " ++ (show params)
346344 -- the time cannot be known, so match around it
347− postOutput = ("POST /\n Accept: \n Status: 200 OK 0", "s\n")
345+ postOutput = (T.pack $ "POST /\n Params: " ++ (show params), "s\n")
348346 getOutput params' = ("GET /location\n Params: " <> T.pack (show params') <> "\n Accept: \n Status: 200 OK 0", "s\n")
349347
350348 debugApp (beginning, ending) req send = do