@@ -48,21 +48,22 @@ type Responder = InternalInfo -> ThreadContinue -> Stream -> Request ->
4848-- They also pass 'Response's from 'Application's to this function.
4949-- This function enqueues commands for the HTTP/2 sender.
5050response :: S.Settings -> Context -> Manager -> Responder
51−response settings Context{outputQ} mgr ii tconf strm req rsp
52− | R.hasBody s0 = case rsp of
53− ResponseStream _ _ strmbdy
54− | isHead -> responseNoBody s0 hs0
55− | otherwise -> responseStreaming strmbdy
56− ResponseBuilder _ _ b
57− | isHead -> responseNoBody s0 hs0
58− | otherwise -> responseBuilderBody s0 hs0 b
59− ResponseFile _ _ p mp -> responseFileXXX p mp
60− ResponseRaw _ _ -> error "HTTP/2 does not support ResponseRaw"
61− | otherwise = responseNoBody s0 hs0
51+response settings Context{outputQ} mgr ii tconf strm req rsp = case rsp of
52+ ResponseStream s0 hs0 strmbdy
53+ | noBody s0 -> responseNoBody s0 hs0
54+ | isHead -> responseNoBody s0 hs0
55+ | otherwise -> responseStreaming s0 hs0 strmbdy
56+ ResponseBuilder s0 hs0 b
57+ | noBody s0 -> responseNoBody s0 hs0
58+ | isHead -> responseNoBody s0 hs0
59+ | otherwise -> responseBuilderBody s0 hs0 b
60+ ResponseFile s0 hs0 p mp
61+ | noBody s0 -> responseNoBody s0 hs0
62+ | otherwise -> responseFileXXX s0 hs0 p mp
63+ ResponseRaw _ _ -> error "HTTP/2 does not support ResponseRaw"
6264 where
65+ noBody = not . R.hasBody
6366 !isHead = requestMethod req == H.methodHead
64− !s0 = responseStatus rsp
65− !hs0 = responseHeaders rsp
6667 !logger = S.settingsLogger settings
6768 !th = threadHandle ii
6869
@@ -88,15 +89,15 @@ response settings Context{outputQ} mgr ii tconf strm req rsp
8889 enqueueOutput outputQ out
8990 return ResponseReceived
9091
91− responseFileXXX path Nothing = do
92+ responseFileXXX _ hs0 path Nothing = do
9293 efinfo <- E.try $ getFileInfo ii path
9394 case efinfo of
94− Left (_ex :: E.IOException) -> response404
95+ Left (_ex :: E.IOException) -> response404 hs0
9596 Right finfo -> case conditionalRequest finfo hs0 (indexRequestHeader (requestHeaders req)) of
9697 WithoutBody s -> responseNoBody s hs0
9798 WithBody s hs beg len -> responseFile2XX s hs path (Just (FilePart beg len (fileInfoSize finfo)))
9899
99− responseFileXXX path mpart = responseFile2XX s0 hs0 path mpart
100+ responseFileXXX s0 hs0 path mpart = responseFile2XX s0 hs0 path mpart
100101
101102 responseFile2XX s hs path mpart
102103 | isHead = do
@@ -110,13 +111,13 @@ response settings Context{outputQ} mgr ii tconf strm req rsp
110111 enqueueOutput outputQ out
111112 return ResponseReceived
112113
113− response404 = responseBuilderBody s hs body
114+ response404 hs0 = responseBuilderBody s hs body
114115 where
115116 s = H.notFound404
116117 hs = R.replaceHeader H.hContentType "text/plain; charset=utf-8" hs0
117118 body = byteString "File not found"
118119
119− responseStreaming strmbdy = do
120+ responseStreaming s0 hs0 strmbdy = do
120121 logger req s0 Nothing
121122 -- We must not exit this WAI application.
122123 -- If the application exits, streaming would be also closed.