on master help sign in
updating doc of sendResponse.
commit9aa9ccd4ce0a317a37728d7b53a0b5f3f06cb269 authorKazu Yamamoto <kazu@iij.ad.jp> dateFri 4 Dec 2015, 12:25 (11 years ago) parent69b8aab
1 file changed+23−18
warp/Network/Wai/Handler/Warp/Response.hs+23−18
warp/Network/Wai/Handler/Warp/Response.hs+23−18
@@ -78,11 +78,11 @@ import qualified Paths_warp
7878
7979-- | Sending a HTTP response to 'Connection' according to 'Response'.
8080--
81−-- Applications/middlewares MUST specify a proper 'H.ResponseHeaders'.
81+-- Applications/middlewares MUST provide a proper 'H.ResponseHeaders'.
8282-- so that inconsistency does not happen.
8383-- No header is deleted by this function.
8484--
85−-- Especially, Applications/middlewares MUST take care of
85+-- Especially, Applications/middlewares MUST take attention to
8686-- Content-Length, Content-Range, and Transfer-Encoding
8787-- because they are inserted, when necessary,
8888-- regardless they already exist.
@@ -94,22 +94,6 @@ import qualified Paths_warp
9494--
9595-- There are three basic APIs to create 'Response':
9696--
97−-- ['responseFile' :: 'H.Status' -> 'H.ResponseHeaders' -> 'FilePath' -> 'Maybe' 'FilePart' -> 'Response']
98−-- HTTP response body is sent by sendfile() for GET method.
99−-- HTTP response body is not sent by HEAD method.
100−-- Applications are categorized into simple and sophisticated.
101−-- Simple applications should specify 'Nothing' to
102−-- 'Maybe' 'FilePart'. The size of the specified file is obtained
103−-- by disk access. Then Range is handled.
104−-- Sophisticated applications should specify 'Just' to
105−-- 'Maybe' 'FilePart'. They should treat Range (and If-Range) by
106−-- themselves. In both cases,
107−-- Content-Length and Content-Range (if necessary) are automatically
108−-- added into the HTTP response header.
109−-- If Content-Length and Content-Range exist in the HTTP response header,
110−-- they would cause inconsistency.
111−-- Status is also changed to 206 (Partial Content) if necessary.
112−--
11397-- ['responseBuilder' :: 'H.Status' -> 'H.ResponseHeaders' -> 'Builder' -> 'Response']
11498-- HTTP response body is created from 'Builder'.
11599-- Transfer-Encoding: chunked is used in HTTP/1.1.
@@ -120,6 +104,27 @@ import qualified Paths_warp
120104--
121105-- ['responseRaw' :: ('IO' 'ByteString' -> ('ByteString' -> 'IO' ()) -> 'IO' ()) -> 'Response' -> 'Response']
122106-- No header is added and no Transfer-Encoding: is applied.
107+--
108+-- ['responseFile' :: 'H.Status' -> 'H.ResponseHeaders' -> 'FilePath' -> 'Maybe' 'FilePart' -> 'Response']
109+-- HTTP response body is sent (by sendfile(), if possible) for GET method.
110+-- HTTP response body is not sent by HEAD method.
111+-- Content-Length and Content-Range are automatically
112+-- added into the HTTP response header if necessary.
113+-- If Content-Length and Content-Range exist in the HTTP response header,
114+-- they would cause inconsistency.
115+-- \"Accept-Ranges: bytes\" is also inserted.
116+--
117+-- Applications are categorized into simple and sophisticated.
118+-- Sophisticated applications should specify 'Just' to
119+-- 'Maybe' 'FilePart'. They should treat the conditional request
120+-- by themselves. A proper 'Status' (200 or 206) must be provided.
121+--
122+-- Simple applications should specify 'Nothing' to
123+-- 'Maybe' 'FilePart'. The size of the specified file is obtained
124+-- by disk access or from the file infor cache.
125+-- If-Modified-Since, If-Unmodified-Since, If-Range and Range
126+-- are processed. Since a proper status is chosen, 'Status' is
127+-- ignored.
123128
124129sendResponse :: Settings
125130 -> Connection