Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete unnecessary isHead plumbing through RspFile #960

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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