on master help sign in
stack.yaml+1−1
since splitsnapshots
unifiedsplit
@@ -1,4 +1,4 @@
1−resolver: lts-14.20
1+resolver: lts-14.22
2packages:
2packages:
3- ./auto-update
3- ./auto-update
4- ./mime-types
4- ./mime-types
wai-app-static/Network/Wai/Application/Static.hs+1−1
@@ -245,7 +245,7 @@ staticAppPieces ss rawPieces req sendResponse = liftIO $ do
245 response :: StaticResponse -> IO W.ResponseReceived
245 response :: StaticResponse -> IO W.ResponseReceived
246 response (FileResponse file ch) = do
246 response (FileResponse file ch) = do
247 mimetype <- ssGetMimeType ss file
247 mimetype <- ssGetMimeType ss file
248− let filesize = fileGetSize file
248+ -- let filesize = fileGetSize file
249 let headers = ("Content-Type", mimetype)
249 let headers = ("Content-Type", mimetype)
250 -- Let Warp provide the content-length, since it takes
250 -- Let Warp provide the content-length, since it takes
251 -- range requests into account
251 -- range requests into account
wai-app-static/WaiAppStatic/CmdLine.hs+1
@@ -39,6 +39,7 @@ data Args = Args
39 }
39 }
40
40
41#if MIN_VERSION_optparse_applicative(0, 10, 0)
41#if MIN_VERSION_optparse_applicative(0, 10, 0)
42+option' :: Mod OptionFields Int -> Parser Int
42option' = option auto
43option' = option auto
43#else
44#else
44option' = option
45option' = option
wai-app-static/WaiAppStatic/Listing.hs+1−1
@@ -64,7 +64,7 @@ defaultListing pieces (Folder contents) = do
64
64
65 -- Add a link to the root of the tree
65 -- Add a link to the root of the tree
66 showFolder' :: Bool -> Pieces -> H.Html
66 showFolder' :: Bool -> Pieces -> H.Html
67− showFolder' hasTrailingSlash pieces = showFolder hasTrailingSlash (unsafeToPiece "root" : pieces)
67+ showFolder' hasTrailingSlash pieces' = showFolder hasTrailingSlash (unsafeToPiece "root" : pieces')
68
68
69 showFolder :: Bool -> Pieces -> H.Html
69 showFolder :: Bool -> Pieces -> H.Html
70 showFolder _ [] = "/" -- won't happen
70 showFolder _ [] = "/" -- won't happen
wai-app-static/WaiAppStatic/Storage/Embedded/TH.hs−1
@@ -7,7 +7,6 @@ module WaiAppStatic.Storage.Embedded.TH(
7
7
8import Data.ByteString.Builder.Extra (byteStringInsert)
8import Data.ByteString.Builder.Extra (byteStringInsert)
9import Codec.Compression.GZip (compress)
9import Codec.Compression.GZip (compress)
10−import Control.Applicative
11import Data.ByteString.Unsafe (unsafePackAddressLen)
10import Data.ByteString.Unsafe (unsafePackAddressLen)
12import Data.Either (lefts, rights)
11import Data.Either (lefts, rights)
13import GHC.Exts (Int(..))
12import GHC.Exts (Int(..))
wai-conduit/Network/Wai/Conduit.hs+5−6
@@ -17,17 +17,16 @@ import qualified Data.ByteString as S
17import Control.Monad (unless)
17import Control.Monad (unless)
18import Network.HTTP.Types
18import Network.HTTP.Types
19import Data.ByteString.Builder (Builder)
19import Data.ByteString.Builder (Builder)
20−import Data.IORef
21import qualified Data.Conduit.List as CL
20import qualified Data.Conduit.List as CL
22
21
23-- | Stream the request body.
22-- | Stream the request body.
24--
23--
25-- Since 3.0.0
24-- Since 3.0.0
26−sourceRequestBody :: MonadIO m => Request -> Source m ByteString
25+sourceRequestBody :: MonadIO m => Request -> ConduitT () ByteString m ()
27sourceRequestBody req =
26sourceRequestBody req =
28 loop
27 loop
29 where
28 where
30− go = liftIO (requestBody req)
29+ go = liftIO (getRequestBodyChunk req)
31
30
32 loop = do
31 loop = do
33 bs <- go
32 bs <- go
@@ -38,9 +37,9 @@ sourceRequestBody req =
38-- | Create an HTTP response out of a @Source@.
37-- | Create an HTTP response out of a @Source@.
39--
38--
40-- Since 3.0.0
39-- Since 3.0.0
41−responseSource :: Status -> ResponseHeaders -> Source IO (Flush Builder) -> Response
40+responseSource :: Status -> ResponseHeaders -> ConduitT () (Flush Builder) IO () -> Response
42responseSource s hs src = responseStream s hs $ \send flush ->
41responseSource s hs src = responseStream s hs $ \send flush ->
43− src $$ CL.mapM_ (\mbuilder ->
42+ runConduit $ src .| CL.mapM_ (\mbuilder ->
44 case mbuilder of
43 case mbuilder of
45 Chunk b -> send b
44 Chunk b -> send b
46 Flush -> flush)
45 Flush -> flush)
@@ -50,7 +49,7 @@ responseSource s hs src = responseStream s hs $ \send flush ->
50--
49--
51-- Since 3.0.0
50-- Since 3.0.0
52responseRawSource :: (MonadIO m, MonadIO n)
51responseRawSource :: (MonadIO m, MonadIO n)
53− => (Source m ByteString -> Sink ByteString n () -> IO ())
52+ => (ConduitT () ByteString m () -> ConduitT ByteString Void n () -> IO ())
54 -> Response
53 -> Response
55 -> Response
54 -> Response
56responseRawSource app =
55responseRawSource app =
wai-extra/ChangeLog.md+4
@@ -1,5 +1,9 @@
1# Changelog for wai-extra
1# Changelog for wai-extra
2
2
3+## 3.0.29.1
4+
5+* Fix `Network.Wai.Test.request` always sending an empty request body [#794](https://github.com/yesodweb/wai/pull/794)
6+
3## 3.0.29
7## 3.0.29
4
8
5* Export `Network.Wai.EventSource.eventStreamAppRaw` [#786](https://github.com/yesodweb/wai/pull/786)
9* Export `Network.Wai.EventSource.eventStreamAppRaw` [#786](https://github.com/yesodweb/wai/pull/786)
wai-extra/Network/Wai/Test.hs+22−14
@@ -99,6 +99,10 @@ runSession session app = ST.evalStateT (runReaderT session app) initState
99data SRequest = SRequest
99data SRequest = SRequest
100 { simpleRequest :: Request
100 { simpleRequest :: Request
101 , simpleRequestBody :: L.ByteString
101 , simpleRequestBody :: L.ByteString
102+ -- ^ Request body that will override the one set in 'simpleRequest'.
103+ --
104+ -- This is usually simpler than setting the body as a stateful IO-action
105+ -- in 'simpleRequest'.
102 }
106 }
103data SResponse = SResponse
107data SResponse = SResponse
104 { simpleStatus :: H.Status
108 { simpleStatus :: H.Status
@@ -106,8 +110,16 @@ data SResponse = SResponse
106 , simpleBody :: L.ByteString
110 , simpleBody :: L.ByteString
107 }
111 }
108 deriving (Show, Eq)
112 deriving (Show, Eq)
113+
109request :: Request -> Session SResponse
114request :: Request -> Session SResponse
110−request = srequest . flip SRequest L.empty
115+request req = do
116+ app <- ask
117+ req' <- addCookiesToRequest req
118+ response <- liftIO $ do
119+ ref <- newIORef $ error "runResponse gave no result"
120+ ResponseReceived <- app req' (runResponse ref)
121+ readIORef ref
122+ extractSetCookieFromSResponse response
111
123
112-- | Set whole path (request path + query string).
124-- | Set whole path (request path + query string).
113setPath :: Request -> S8.ByteString -> Request
125setPath :: Request -> S8.ByteString -> Request
@@ -166,22 +178,18 @@ extractSetCookieFromSResponse response = do
166 (Map.fromList [(Cookie.setCookieName c, c) | c <- newClientCookies ]))
178 (Map.fromList [(Cookie.setCookieName c, c) | c <- newClientCookies ]))
167 return response
179 return response
168
180
181+-- | Similar to 'request', but allows setting the request body as a plain
182+-- 'L.ByteString'.
169srequest :: SRequest -> Session SResponse
183srequest :: SRequest -> Session SResponse
170srequest (SRequest req bod) = do
184srequest (SRequest req bod) = do
171− app <- ask
172 refChunks <- liftIO $ newIORef $ L.toChunks bod
185 refChunks <- liftIO $ newIORef $ L.toChunks bod
186+ request $
173− let req' = req
187+ req
174− { requestBody = atomicModifyIORef refChunks $ \bss ->
188+ { requestBody = atomicModifyIORef refChunks $ \bss ->
175− case bss of
189+ case bss of
176− [] -> ([], S.empty)
190+ [] -> ([], S.empty)
177− x:y -> (y, x)
191+ x:y -> (y, x)
178− }
192+ }
179− req'' <- addCookiesToRequest req'
180− response <- liftIO $ do
181− ref <- newIORef $ error "runResponse gave no result"
182− ResponseReceived <- app req'' (runResponse ref)
183− readIORef ref
184− extractSetCookieFromSResponse response
185
193
186runResponse :: IORef SResponse -> Response -> IO ResponseReceived
194runResponse :: IORef SResponse -> Response -> IO ResponseReceived
187runResponse ref res = do
195runResponse ref res = do
wai-extra/example/Main.hs+2−2
@@ -42,10 +42,10 @@ eventRaw = handle 0
42 where
42 where
43 handle counter emit flush = do
43 handle counter emit flush = do
44 threadDelay 1000000
44 threadDelay 1000000
45− emit $ ServerEvent (Just $ string8 "raw")
45+ _ <- emit $ ServerEvent (Just $ string8 "raw")
46 Nothing
46 Nothing
47 [string8 . show $ counter]
47 [string8 . show $ counter]
48− flush
48+ _ <- flush
49 handle (counter + 1) emit flush
49 handle (counter + 1) emit flush
50
50
51main :: IO ()
51main :: IO ()
wai-extra/test/Network/Wai/TestSpec.hs+41−11
@@ -3,6 +3,8 @@ module Network.Wai.TestSpec (main, spec) where
3
3
4import Control.Monad (void)
4import Control.Monad (void)
5
5
6+import qualified Data.IORef as IORef
7+
6import qualified Data.Text.Encoding as TE
8import qualified Data.Text.Encoding as TE
7
9
8import Data.Time.Calendar (fromGregorian)
10import Data.Time.Calendar (fromGregorian)
@@ -53,25 +55,53 @@ spec = do
53 it "sets rawQueryString to empty string" $ do
55 it "sets rawQueryString to empty string" $ do
54 rawQueryString (setPath defaultRequest "/foo/bar/baz") `shouldBe` ""
56 rawQueryString (setPath defaultRequest "/foo/bar/baz") `shouldBe` ""
55
57
58+ describe "srequest" $ do
59+
60+ let echoApp req respond = do
61+ reqBody <- L8.fromStrict <$> getRequestBodyChunk req
62+ let reqHeaders = requestHeaders req
63+ respond $
64+ responseLBS
65+ status200
66+ reqHeaders
67+ reqBody
68+
69+ it "returns the response body of an echo app" $ do
70+ sresp <- flip runSession echoApp $
71+ srequest $ SRequest defaultRequest "request body"
72+ simpleBody sresp `shouldBe` "request body"
73+
56 describe "request" $ do
74 describe "request" $ do
57
75
58− let simpleApp _req respond =
76+ let echoApp req respond = do
77+ reqBody <- L8.fromStrict <$> getRequestBodyChunk req
78+ let reqHeaders = requestHeaders req
59 respond $
79 respond $
60 responseLBS
80 responseLBS
61 status200
81 status200
62− [("foo", "bar")]
82+ reqHeaders
63− "simple"
83+ reqBody
64
84
65− it "returns the status code of a simple app on default request" $ do
85+ it "returns the status code of an echo app on default request" $ do
66− sresp <- runSession (request defaultRequest) simpleApp
86+ sresp <- runSession (request defaultRequest) echoApp
67 simpleStatus sresp `shouldBe` status200
87 simpleStatus sresp `shouldBe` status200
68
88
69− it "returns the response body of a simple app on default request" $ do
89+ it "returns the response body of an echo app" $ do
90+ bodyRef <- IORef.newIORef "request body"
91+ let getBodyChunk = IORef.atomicModifyIORef bodyRef $ \leftover -> ("", leftover)
92+ sresp <- flip runSession echoApp $
93+ request $
70− sresp <- runSession (request defaultRequest) simpleApp
94+ defaultRequest
95+ { requestBody = getBodyChunk
96+ }
71− simpleBody sresp `shouldBe` "simple"
97+ simpleBody sresp `shouldBe` "request body"
72−
98+
73− it "returns the response headers of a simple app on default request" $ do
99+ it "returns the response headers of an echo app" $ do
100+ sresp <- flip runSession echoApp $
101+ request $
74− sresp <- runSession (request defaultRequest) simpleApp
102+ defaultRequest
103+ { requestHeaders = [("foo", "bar")]
104+ }
75 simpleHeaders sresp `shouldBe` [("foo", "bar")]
105 simpleHeaders sresp `shouldBe` [("foo", "bar")]
76
106
77 let cookieApp req respond =
107 let cookieApp req respond =
wai-extra/wai-extra.cabal+1−1
@@ -1,5 +1,5 @@
1Name: wai-extra
1Name: wai-extra
2−Version: 3.0.29
2+Version: 3.0.29.1
3Synopsis: Provides some basic WAI handlers and middleware.
3Synopsis: Provides some basic WAI handlers and middleware.
4description:
4description:
5 Provides basic WAI handler and middleware functionality:
5 Provides basic WAI handler and middleware functionality:
wai-websockets/server.lhs+6
@@ -8,6 +8,8 @@ this example, keep the [reference](http://jaspervdj.be/websockets/reference)
8nearby to check out the functions we use.
8nearby to check out the functions we use.
9
9
10> {-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
10> {-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
11+> {-# LANGUAGE CPP #-}
12+> {-# OPTIONS_GHC -Wno-unused-top-binds #-} -- for numClients
11> import Data.Char (isPunctuation, isSpace)
13> import Data.Char (isPunctuation, isSpace)
12> import Data.Monoid (mappend)
14> import Data.Monoid (mappend)
13> import Data.Text (Text)
15> import Data.Text (Text)
@@ -99,7 +101,11 @@ stays alive on some browsers.
99
101
100> application state pending = do
102> application state pending = do
101> conn <- WS.acceptRequest pending
103> conn <- WS.acceptRequest pending
104+#if __GLASGOW_HASKELL__ >= 806
105+> WS.withPingThread conn 30 (return ()) $ do
106+#else
102> WS.forkPingThread conn 30
107> WS.forkPingThread conn 30
108+#endif
103
109
104When a client is successfully connected, we read the first message. This should
110When a client is successfully connected, we read the first message. This should
105be in the format of "Hi! I am Jasper", where Jasper is the requested username.
111be in the format of "Hi! I am Jasper", where Jasper is the requested username.
wai-websockets/wai-websockets.cabal+1
@@ -45,6 +45,7 @@ Executable wai-websockets-example
45 , text
45 , text
46 , file-embed
46 , file-embed
47 , http-types
47 , http-types
48+ other-modules: Network.Wai.Handler.WebSockets
48 else
49 else
49 buildable: False
50 buildable: False
50
51
warp/ChangeLog.md+5
@@ -1,3 +1,8 @@
1+## 3.3.9
2+
3+* Don't insert Last-Modified: if exists.
4+ [#791](https://github.com/yesodweb/wai/pull/791)
5+
1## 3.3.8
6## 3.3.8
2
7
3* Maximum header size is configurable.
8* Maximum header size is configurable.
warp/Network/Wai/Handler/Warp/File.hs+7−4
@@ -34,12 +34,15 @@ data RspFileInfo = WithoutBody H.Status
34----------------------------------------------------------------
34----------------------------------------------------------------
35
35
36conditionalRequest :: I.FileInfo
36conditionalRequest :: I.FileInfo
37− -> H.ResponseHeaders -> IndexedHeader
37+ -> H.ResponseHeaders
38+ -> IndexedHeader -- ^ Response
39+ -> IndexedHeader -- ^ Request
38 -> RspFileInfo
40 -> RspFileInfo
39−conditionalRequest finfo hs0 reqidx = case condition of
41+conditionalRequest finfo hs0 rspidx reqidx = case condition of
40 nobody@(WithoutBody _) -> nobody
42 nobody@(WithoutBody _) -> nobody
43+ WithBody s _ off len -> let !hs1 = addContentHeaders hs0 off len size
44+ !hasLM = isJust $ rspidx ! fromEnum ResLastModified
41− WithBody s _ off len -> let !hs = (H.hLastModified,date) :
45+ !hs = [ (H.hLastModified,date) | not hasLM ] ++ hs1
42− addContentHeaders hs0 off len size
43 in WithBody s hs off len
46 in WithBody s hs off len
44 where
47 where
45 !mtime = I.fileInfoTime finfo
48 !mtime = I.fileInfoTime finfo
warp/Network/Wai/Handler/Warp/HTTP2/Response.hs+2−1
@@ -72,7 +72,8 @@ responseFile _ rsphdr isHead path Nothing ii reqhdr = do
72 Left (_ex :: E.IOException) -> return $ response404 rsphdr
72 Left (_ex :: E.IOException) -> return $ response404 rsphdr
73 Right finfo -> do
73 Right finfo -> do
74 let reqidx = indexRequestHeader reqhdr
74 let reqidx = indexRequestHeader reqhdr
75+ rspidx = indexResponseHeader rsphdr
75− case conditionalRequest finfo rsphdr reqidx of
76+ case conditionalRequest finfo rsphdr rspidx reqidx of
76 WithoutBody s -> return $ responseNoBody s rsphdr
77 WithoutBody s -> return $ responseNoBody s rsphdr
77 WithBody s rsphdr' off bytes -> do
78 WithBody s rsphdr' off bytes -> do
78 let !off' = fromIntegral off
79 let !off' = fromIntegral off
warp/Network/Wai/Handler/Warp/Header.hs+2
@@ -69,6 +69,7 @@ indexResponseHeader hdr = traverseHeader hdr responseMaxIndex responseKeyIndex
69data ResponseHeaderIndex = ResContentLength
69data ResponseHeaderIndex = ResContentLength
70 | ResServer
70 | ResServer
71 | ResDate
71 | ResDate
72+ | ResLastModified
72 deriving (Enum,Bounded)
73 deriving (Enum,Bounded)
73
74
74-- | The size for 'IndexedHeader' for HTTP Response.
75-- | The size for 'IndexedHeader' for HTTP Response.
@@ -79,6 +80,7 @@ responseKeyIndex :: HeaderName -> Int
79responseKeyIndex hn = case BS.length bs of
80responseKeyIndex hn = case BS.length bs of
80 4 -> if bs == "date" then fromEnum ResDate else -1
81 4 -> if bs == "date" then fromEnum ResDate else -1
81 6 -> if bs == "server" then fromEnum ResServer else -1
82 6 -> if bs == "server" then fromEnum ResServer else -1
83+ 13 -> if bs == "last-modified" then fromEnum ResLastModified else -1
82 14 -> if bs == "content-length" then fromEnum ResContentLength else -1
84 14 -> if bs == "content-length" then fromEnum ResContentLength else -1
83 _ -> -1
85 _ -> -1
84 where
86 where
warp/Network/Wai/Handler/Warp/Recv.hs+2
@@ -153,6 +153,8 @@ receiveloop sock ptr size = do
153 else
153 else
154 return bytes
154 return bytes
155
155
156+#ifndef mingw32_HOST_OS
156-- fixme: the type of the return value
157-- fixme: the type of the return value
157foreign import ccall unsafe "recv"
158foreign import ccall unsafe "recv"
158 c_recv :: CInt -> Ptr CChar -> CSize -> CInt -> IO CInt
159 c_recv :: CInt -> Ptr CChar -> CSize -> CInt -> IO CInt
160+#endif
warp/Network/Wai/Handler/Warp/Response.hs+19−16
@@ -116,14 +116,14 @@ sendResponse settings conn ii th req reqidxhdr src response = do
116 -- and status, the response to HEAD is processed here.
116 -- and status, the response to HEAD is processed here.
117 --
117 --
118 -- See definition of rsp below for proper body stripping.
118 -- See definition of rsp below for proper body stripping.
119− (ms, mlen) <- sendRsp conn ii ver s hs rsp
119+ (ms, mlen) <- sendRsp conn ii ver s hs rspidxhdr rsp
120 case ms of
120 case ms of
121 Nothing -> return ()
121 Nothing -> return ()
122 Just realStatus -> logger req realStatus mlen
122 Just realStatus -> logger req realStatus mlen
123 T.tickle th
123 T.tickle th
124 return ret
124 return ret
125 else do
125 else do
126− _ <- sendRsp conn ii ver s hs RspNoBody
126+ _ <- sendRsp conn ii ver s hs rspidxhdr RspNoBody
127 logger req s Nothing
127 logger req s Nothing
128 T.tickle th
128 T.tickle th
129 return isPersist
129 return isPersist
@@ -196,12 +196,13 @@ sendRsp :: Connection
196 -> H.HttpVersion
196 -> H.HttpVersion
197 -> H.Status
197 -> H.Status
198 -> H.ResponseHeaders
198 -> H.ResponseHeaders
199+ -> IndexedHeader -- Response
199 -> Rsp
200 -> Rsp
200 -> IO (Maybe H.Status, Maybe Integer)
201 -> IO (Maybe H.Status, Maybe Integer)
201
202
202----------------------------------------------------------------
203----------------------------------------------------------------
203
204
204−sendRsp conn _ ver s hs RspNoBody = do
205+sendRsp conn _ ver s hs _ RspNoBody = do
205 -- Not adding Content-Length.
206 -- Not adding Content-Length.
206 -- User agents treats it as Content-Length: 0.
207 -- User agents treats it as Content-Length: 0.
207 composeHeader ver s hs >>= connSendAll conn
208 composeHeader ver s hs >>= connSendAll conn
@@ -209,7 +210,7 @@ sendRsp conn _ ver s hs RspNoBody = do
209
210
210----------------------------------------------------------------
211----------------------------------------------------------------
211
212
212−sendRsp conn _ ver s hs (RspBuilder body needsChunked) = do
213+sendRsp conn _ ver s hs _ (RspBuilder body needsChunked) = do
213 header <- composeHeaderBuilder ver s hs needsChunked
214 header <- composeHeaderBuilder ver s hs needsChunked
214 let hdrBdy
215 let hdrBdy
215 | needsChunked = header <> chunkedTransferEncoding body
216 | needsChunked = header <> chunkedTransferEncoding body
@@ -222,7 +223,7 @@ sendRsp conn _ ver s hs (RspBuilder body needsChunked) = do
222
223
223----------------------------------------------------------------
224----------------------------------------------------------------
224
225
225−sendRsp conn _ ver s hs (RspStream streamingBody needsChunked th) = do
226+sendRsp conn _ ver s hs _ (RspStream streamingBody needsChunked th) = do
226 header <- composeHeaderBuilder ver s hs needsChunked
227 header <- composeHeaderBuilder ver s hs needsChunked
227 (recv, finish) <- newByteStringBuilderRecv $ reuseBufferStrategy
228 (recv, finish) <- newByteStringBuilderRecv $ reuseBufferStrategy
228 $ toBuilderBuffer (connWriteBuffer conn) (connBufferSize conn)
229 $ toBuilderBuffer (connWriteBuffer conn) (connBufferSize conn)
@@ -246,7 +247,7 @@ sendRsp conn _ ver s hs (RspStream streamingBody needsChunked th) = do
246
247
247----------------------------------------------------------------
248----------------------------------------------------------------
248
249
249−sendRsp conn _ _ _ _ (RspRaw withApp src tickle) = do
250+sendRsp conn _ _ _ _ _ (RspRaw withApp src tickle) = do
250 withApp recv send
251 withApp recv send
251 return (Nothing, Nothing)
252 return (Nothing, Nothing)
252 where
253 where
@@ -260,8 +261,8 @@ sendRsp conn _ _ _ _ (RspRaw withApp src tickle) = do
260
261
261-- Sophisticated WAI applications.
262-- Sophisticated WAI applications.
262-- We respect s0. s0 MUST be a proper value.
263-- We respect s0. s0 MUST be a proper value.
263−sendRsp conn ii ver s0 hs0 (RspFile path (Just part) _ isHead hook) =
264+sendRsp conn ii ver s0 hs0 rspidxhdr (RspFile path (Just part) _ isHead hook) =
264− sendRspFile2XX conn ii ver s0 hs path beg len isHead hook
265+ sendRspFile2XX conn ii ver s0 hs rspidxhdr path beg len isHead hook
265 where
266 where
266 beg = filePartOffset part
267 beg = filePartOffset part
267 len = filePartByteCount part
268 len = filePartByteCount part
@@ -271,17 +272,17 @@ sendRsp conn ii ver s0 hs0 (RspFile path (Just part) _ isHead hook) =
271
272
272-- Simple WAI applications.
273-- Simple WAI applications.
273-- Status is ignored
274-- Status is ignored
274−sendRsp conn ii ver _ hs0 (RspFile path Nothing idxhdr isHead hook) = do
275+sendRsp conn ii ver _ hs0 rspidxhdr (RspFile path Nothing reqidxhdr isHead hook) = do
275 efinfo <- E.try $ getFileInfo ii path
276 efinfo <- E.try $ getFileInfo ii path
276 case efinfo of
277 case efinfo of
277 Left (_ex :: E.IOException) ->
278 Left (_ex :: E.IOException) ->
278#ifdef WARP_DEBUG
279#ifdef WARP_DEBUG
279 print _ex >>
280 print _ex >>
280#endif
281#endif
281− sendRspFile404 conn ii ver hs0
282+ sendRspFile404 conn ii ver hs0 rspidxhdr
282− Right finfo -> case conditionalRequest finfo hs0 idxhdr of
283+ Right finfo -> case conditionalRequest finfo hs0 rspidxhdr reqidxhdr of
283− WithoutBody s -> sendRsp conn ii ver s hs0 RspNoBody
284+ WithoutBody s -> sendRsp conn ii ver s hs0 rspidxhdr RspNoBody
284− WithBody s hs beg len -> sendRspFile2XX conn ii ver s hs path beg len isHead hook
285+ WithBody s hs beg len -> sendRspFile2XX conn ii ver s hs rspidxhdr path beg len isHead hook
285
286
286----------------------------------------------------------------
287----------------------------------------------------------------
287
288
@@ -290,14 +291,15 @@ sendRspFile2XX :: Connection
290 -> H.HttpVersion
291 -> H.HttpVersion
291 -> H.Status
292 -> H.Status
292 -> H.ResponseHeaders
293 -> H.ResponseHeaders
294+ -> IndexedHeader
293 -> FilePath
295 -> FilePath
294 -> Integer
296 -> Integer
295 -> Integer
297 -> Integer
296 -> Bool
298 -> Bool
297 -> IO ()
299 -> IO ()
298 -> IO (Maybe H.Status, Maybe Integer)
300 -> IO (Maybe H.Status, Maybe Integer)
299−sendRspFile2XX conn ii ver s hs path beg len isHead hook
301+sendRspFile2XX conn ii ver s hs rspidxhdr path beg len isHead hook
300− | isHead = sendRsp conn ii ver s hs RspNoBody
302+ | isHead = sendRsp conn ii ver s hs rspidxhdr RspNoBody
301 | otherwise = do
303 | otherwise = do
302 lheader <- composeHeader ver s hs
304 lheader <- composeHeader ver s hs
303 (mfd, fresher) <- getFd ii path
305 (mfd, fresher) <- getFd ii path
@@ -310,8 +312,9 @@ sendRspFile404 :: Connection
310 -> InternalInfo
312 -> InternalInfo
311 -> H.HttpVersion
313 -> H.HttpVersion
312 -> H.ResponseHeaders
314 -> H.ResponseHeaders
315+ -> IndexedHeader
313 -> IO (Maybe H.Status, Maybe Integer)
316 -> IO (Maybe H.Status, Maybe Integer)
314−sendRspFile404 conn ii ver hs0 = sendRsp conn ii ver s hs (RspBuilder body True)
317+sendRspFile404 conn ii ver hs0 rspidxhdr = sendRsp conn ii ver s hs rspidxhdr (RspBuilder body True)
315 where
318 where
316 s = H.notFound404
319 s = H.notFound404
317 hs = replaceHeader H.hContentType "text/plain; charset=utf-8" hs0
320 hs = replaceHeader H.hContentType "text/plain; charset=utf-8" hs0
warp/Network/Wai/Handler/Warp/Run.hs+4
@@ -59,7 +59,11 @@ import Network.Socket (fdSocket)
59
59
60-- | Creating 'Connection' for plain HTTP based on a given socket.
60-- | Creating 'Connection' for plain HTTP based on a given socket.
61socketConnection :: Settings -> Socket -> IO Connection
61socketConnection :: Settings -> Socket -> IO Connection
62+#if MIN_VERSION_network(3,1,1)
62socketConnection set s = do
63socketConnection set s = do
64+#else
65+socketConnection _ s = do
66+#endif
63 bufferPool <- newBufferPool
67 bufferPool <- newBufferPool
64 writeBuf <- allocateBuffer bufferSize
68 writeBuf <- allocateBuffer bufferSize
65 let sendall = Sock.sendAll s
69 let sendall = Sock.sendAll s
warp/test/FileSpec.hs+1−1
@@ -21,7 +21,7 @@ testFileRange desc reqhs file ans = it desc $ do
21 let WithBody s hs off len = ans
21 let WithBody s hs off len = ans
22 hs' = ("Last-Modified",fileInfoDate finfo) : hs
22 hs' = ("Last-Modified",fileInfoDate finfo) : hs
23 ans' = WithBody s hs' off len
23 ans' = WithBody s hs' off len
24− conditionalRequest finfo [] (indexRequestHeader reqhs) `shouldBe` ans'
24+ conditionalRequest finfo [] (indexResponseHeader hs) (indexRequestHeader reqhs) `shouldBe` ans'
25
25
26spec :: Spec
26spec :: Spec
27spec = do
27spec = do
warp/warp.cabal+1−1
@@ -1,5 +1,5 @@
1Name: warp
1Name: warp
2−Version: 3.3.8
2+Version: 3.3.9
3Synopsis: A fast, light-weight web server for WAI applications.
3Synopsis: A fast, light-weight web server for WAI applications.
4License: MIT
4License: MIT
5License-file: LICENSE
5License-file: LICENSE