on master help sign in
fix test now that the request logger logs the body
c010a28Greg Weber
wai-extra/Network/Wai/Middleware/RequestLogger.hs+4−2
@@ -248,9 +248,11 @@ detailedMiddleware' :: Callback
248 -> Middleware
248 -> Middleware
249detailedMiddleware' cb ansiColor ansiMethod ansiStatusCode app req sendResponse = do
249detailedMiddleware' cb ansiColor ansiMethod ansiStatusCode app req sendResponse = do
250 (req', body) <-
250 (req', body) <-
251+ -- second tuple item should not be necessary, but a test runner might mess it up
251− case requestBodyLength req of
252+ case (requestBodyLength req, contentLength (requestHeaders req)) of
252 -- log the request body if it is small
253 -- log the request body if it is small
254+ (KnownLength len, _) | len <= 2048 -> getRequestBody req
253− KnownLength len | len <= 2048 -> getRequestBody req
255+ (_, Just len) | len <= 2048 -> getRequestBody req
254 _ -> return (req, [])
256 _ -> return (req, [])
255
257
256 let reqbodylog _ = if null body then [""] else ansiColor White " Request Body: " <> body <> ["\n"]
258 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
341 }
341 }
342 where
342 where
343 params = [("foo", "bar"), ("baz", "bin")]
343 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)
346 -- the time cannot be known, so match around it
344 -- 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")
348 getOutput params' = ("GET /location\n Params: " <> T.pack (show params') <> "\n Accept: \n Status: 200 OK 0", "s\n")
346 getOutput params' = ("GET /location\n Params: " <> T.pack (show params') <> "\n Accept: \n Status: 200 OK 0", "s\n")
349
347
350 debugApp (beginning, ending) req send = do
348 debugApp (beginning, ending) req send = do