Skip to content

Commit

Permalink
Merge PR #960
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Dec 22, 2023
2 parents 7fba10f + fe708a2 commit c92d7b1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions warp/Network/Wai/Handler/Warp/Response.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ sendResponse settings conn ii th req reqidxhdr src response = do
method = requestMethod req
isHead = method == H.methodHead
rsp = case response of
ResponseFile _ _ path mPart -> RspFile path mPart reqidxhdr isHead (T.tickle th)
ResponseFile _ _ path mPart -> RspFile path mPart reqidxhdr (T.tickle th)
ResponseBuilder _ _ b
| isHead -> RspNoBody
| otherwise -> RspBuilder b needsChunked
Expand Down Expand Up @@ -188,7 +188,7 @@ sanitizeHeaderValue v = case C8.lines $ S.filter (/= _cr) v of
----------------------------------------------------------------

data Rsp = RspNoBody
| RspFile FilePath (Maybe FilePart) IndexedHeader Bool (IO ())
| RspFile FilePath (Maybe FilePart) IndexedHeader (IO ())
| RspBuilder Builder Bool
| RspStream StreamingBody Bool
| RspRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) (IO ByteString)
Expand Down Expand Up @@ -267,8 +267,8 @@ sendRsp conn _ th _ _ _ _ _ _ (RspRaw withApp src) = do

-- Sophisticated WAI applications.
-- We respect s0. s0 MUST be a proper value.
sendRsp conn ii th ver s0 hs0 rspidxhdr maxRspBufSize method (RspFile path (Just part) _ isHead hook) =
sendRspFile2XX conn ii th ver s0 hs rspidxhdr maxRspBufSize method path beg len isHead hook
sendRsp conn ii th ver s0 hs0 rspidxhdr maxRspBufSize method (RspFile path (Just part) _ hook) =
sendRspFile2XX conn ii th ver s0 hs rspidxhdr maxRspBufSize method path beg len hook
where
beg = filePartOffset part
len = filePartByteCount part
Expand All @@ -278,7 +278,7 @@ sendRsp conn ii th ver s0 hs0 rspidxhdr maxRspBufSize method (RspFile path (Just

-- Simple WAI applications.
-- Status is ignored
sendRsp conn ii th ver _ hs0 rspidxhdr maxRspBufSize method (RspFile path Nothing reqidxhdr isHead hook) = do
sendRsp conn ii th ver _ hs0 rspidxhdr maxRspBufSize method (RspFile path Nothing reqidxhdr hook) = do
efinfo <- UnliftIO.tryIO $ getFileInfo ii path
case efinfo of
Left (_ex :: UnliftIO.IOException) ->
Expand All @@ -288,7 +288,7 @@ sendRsp conn ii th ver _ hs0 rspidxhdr maxRspBufSize method (RspFile path Nothin
sendRspFile404 conn ii th ver hs0 rspidxhdr maxRspBufSize method
Right finfo -> case conditionalRequest finfo hs0 method rspidxhdr reqidxhdr of
WithoutBody s -> sendRsp conn ii th ver s hs0 rspidxhdr maxRspBufSize method RspNoBody
WithBody s hs beg len -> sendRspFile2XX conn ii th ver s hs rspidxhdr maxRspBufSize method path beg len isHead hook
WithBody s hs beg len -> sendRspFile2XX conn ii th ver s hs rspidxhdr maxRspBufSize method path beg len hook

----------------------------------------------------------------

Expand All @@ -304,11 +304,10 @@ sendRspFile2XX :: Connection
-> FilePath
-> Integer
-> Integer
-> Bool
-> IO ()
-> IO (Maybe H.Status, Maybe Integer)
sendRspFile2XX conn ii th ver s hs rspidxhdr maxRspBufSize method path beg len isHead hook
| isHead = sendRsp conn ii th ver s hs rspidxhdr maxRspBufSize method RspNoBody
sendRspFile2XX conn ii th ver s hs rspidxhdr maxRspBufSize method path beg len hook
| method == H.methodHead = sendRsp conn ii th ver s hs rspidxhdr maxRspBufSize method RspNoBody
| otherwise = do
lheader <- composeHeader ver s hs
(mfd, fresher) <- getFd ii path
Expand Down

0 comments on commit c92d7b1

Please sign in to comment.