on master help sign in
Merge pull request #291 from ndmitchell/master

#290, add a Show instance for Request. Things which can't be shown are shown as their type.

commit64b864a0b0ed47d18e60d0587c5da978a4c6d6cd authorMichael Snoyman <michael@snoyman.com> dateWed 1 Oct 2014, 20:54 (12 years ago) parent652a7a0a28e8a0
1 file changed+24−1
wai/Network/Wai/Internal.hs+24−1
wai/Network/Wai/Internal.hs+24−1
@@ -2,6 +2,7 @@
22{-# LANGUAGE DeriveDataTypeable #-}
33{-# LANGUAGE CPP #-}
44{-# LANGUAGE RankNTypes #-}
5+{-# LANGUAGE RecordWildCards #-}
56-- | Internal constructors and helper functions. Note that no guarantees are
67-- given for stability of these interfaces.
78module Network.Wai.Internal where
@@ -14,6 +15,7 @@ import Data.Vault.Lazy (Vault)
1415import Data.Word (Word64)
1516import qualified Network.HTTP.Types as H
1617import Network.Socket (SockAddr)
18+import Data.List (intercalate)
1719
1820-- | Information on the request sent by the client. This abstracts away the
1921-- details of the underlying implementation.
@@ -71,6 +73,27 @@ data Request = Request {
7173 }
7274 deriving (Typeable)
7375
76+instance Show Request where
77+ show Request{..} = "Request {" ++ intercalate ", " [a ++ " = " ++ b | (a,b) <- fields] ++ "}"
78+ where
79+ fields =
80+ [("requestMethod",show requestMethod)
81+ ,("httpVersion",show httpVersion)
82+ ,("rawPathInfo",show rawPathInfo)
83+ ,("rawQueryString",show rawQueryString)
84+ ,("requestHeaders",show requestHeaders)
85+ ,("isSecure",show isSecure)
86+ ,("remoteHost",show remoteHost)
87+ ,("pathInfo",show pathInfo)
88+ ,("queryString",show queryString)
89+ ,("requestBody","<IO ByteString>")
90+ ,("vault","<Vault>")
91+ ,("requestBodyLength",show requestBodyLength)
92+ ,("requestHeaderHost",show requestHeaderHost)
93+ ,("requestHeaderRange",show requestHeaderRange)
94+ ]
95+
96+
7497data Response
7598 = ResponseFile H.Status H.ResponseHeaders FilePath (Maybe FilePart)
7699 | ResponseBuilder H.Status H.ResponseHeaders Builder
@@ -90,7 +113,7 @@ type StreamingBody = (Builder -> IO ()) -> IO () -> IO ()
90113-- not be known.
91114--
92115-- Since 1.4.0
93−data RequestBodyLength = ChunkedBody | KnownLength Word64
116+data RequestBodyLength = ChunkedBody | KnownLength Word64 deriving Show
94117
95118-- | Information on which part to be sent.
96119-- Sophisticated application handles Range (and If-Range) then