on master help sign in
Defining warpVersionHeader.
commiteddfe03beb6170318a49efd9ee57d9df35ac2bb5 authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 15 Aug 2012, 12:48 (14 years ago) parenta4ebdd5
2 files changed+14−6
warp/Network/Wai/Handler/Warp/Response.hs+11−6 warp/Network/Wai/Handler/Warp/Types.hs+3
warp/Network/Wai/Handler/Warp/Response.hs+11−6
@@ -167,6 +167,8 @@ responseHeaderToBuilder b (x, y) = b
167167 `mappend` copyByteString y
168168 `mappend` newlineBuilder
169169
170+----------------------------------------------------------------
171+
170172-- | Use 'connSendAll' to send this data while respecting timeout rules.
171173connSink :: Connection -> T.Handle -> Sink B.ByteString (ResourceT IO) ()
172174connSink Connection { connSendAll = send } th =
@@ -184,11 +186,14 @@ connSink Connection { connSendAll = send } th =
184186 -- also make sure to resume the timeout after the completion of user code
185187 -- so that we can kill idle connections.
186188
189+----------------------------------------------------------------
190+
187191serverHeader :: H.RequestHeaders -> H.RequestHeaders
188−serverHeader hdrs = case lookup key hdrs of
189− Nothing -> server : hdrs
190− Just _ -> hdrs
191− where
192− key = "Server"
192+serverHeader hdrs = case lookup hServer hdrs of
193+ Nothing -> warpVersionHeader : hdrs
194+ Just _ -> hdrs
195+
196+warpVersionHeader :: H.Header
197+warpVersionHeader = (hServer, ver)
198+ where
193199 ver = B.pack $ "Warp/" ++ warpVersion
194− server = (key, ver)
warp/Network/Wai/Handler/Warp/Types.hs+3
@@ -29,6 +29,9 @@ hTransferEncoding = "Transfer-Encoding"
2929hHost :: HeaderName
3030hHost = "Host"
3131
32+hServer :: HeaderName
33+hServer = "Server"
34+
3235----------------------------------------------------------------
3336
3437data InvalidRequest =