on master help sign in
Defining warpVersionHeader.
eddfe03Kazu Yamamoto
warp/Network/Wai/Handler/Warp/Response.hs+11−6
@@ -167,6 +167,8 @@ responseHeaderToBuilder b (x, y) = b
167 `mappend` copyByteString y
167 `mappend` copyByteString y
168 `mappend` newlineBuilder
168 `mappend` newlineBuilder
169
169
170+----------------------------------------------------------------
171+
170-- | Use 'connSendAll' to send this data while respecting timeout rules.
172-- | Use 'connSendAll' to send this data while respecting timeout rules.
171connSink :: Connection -> T.Handle -> Sink B.ByteString (ResourceT IO) ()
173connSink :: Connection -> T.Handle -> Sink B.ByteString (ResourceT IO) ()
172connSink Connection { connSendAll = send } th =
174connSink Connection { connSendAll = send } th =
@@ -184,11 +186,14 @@ connSink Connection { connSendAll = send } th =
184 -- also make sure to resume the timeout after the completion of user code
186 -- also make sure to resume the timeout after the completion of user code
185 -- so that we can kill idle connections.
187 -- so that we can kill idle connections.
186
188
189+----------------------------------------------------------------
190+
187serverHeader :: H.RequestHeaders -> H.RequestHeaders
191serverHeader :: H.RequestHeaders -> H.RequestHeaders
188−serverHeader hdrs = case lookup key hdrs of
192+serverHeader hdrs = case lookup hServer hdrs of
189− Nothing -> server : hdrs
193+ Nothing -> warpVersionHeader : hdrs
190− Just _ -> hdrs
194+ Just _ -> hdrs
195+
196+warpVersionHeader :: H.Header
197+warpVersionHeader = (hServer, ver)
191− where
198+ where
192− key = "Server"
193 ver = B.pack $ "Warp/" ++ warpVersion
199 ver = B.pack $ "Warp/" ++ warpVersion
194− server = (key, ver)
warp/Network/Wai/Handler/Warp/Types.hs+3
@@ -29,6 +29,9 @@ hTransferEncoding = "Transfer-Encoding"
29hHost :: HeaderName
29hHost :: HeaderName
30hHost = "Host"
30hHost = "Host"
31
31
32+hServer :: HeaderName
33+hServer = "Server"
34+
32----------------------------------------------------------------
35----------------------------------------------------------------
33
36
34data InvalidRequest =
37data InvalidRequest =