{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Network.Wai.Application.Classic.Header where
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS (tail,break)
import Network.HTTP.Types.Header
import Network.Wai
hIfUnmodifiedSince :: HeaderName
hIfUnmodifiedSince :: HeaderName
hIfUnmodifiedSince = "if-unmodified-since"
hStatus :: HeaderName
hStatus :: HeaderName
hStatus = "status"
hXForwardedFor :: HeaderName
hXForwardedFor :: HeaderName
hXForwardedFor = "x-forwarded-for"
hVia :: HeaderName
hVia :: HeaderName
hVia = "via"
hTransferEncoding :: HeaderName
hTransferEncoding :: HeaderName
hTransferEncoding = "transfer-encoding"
hAcceptEncoding :: HeaderName
hAcceptEncoding :: HeaderName
hAcceptEncoding = "accept-encoding"
hostPort :: Request -> (ByteString, ByteString)
hostPort :: Request -> (ByteString, ByteString)
hostPort req :: Request
req = case Request -> Maybe ByteString
requestHeaderHost Request
req of
Nothing -> ("Unknown","80")
Just hostport :: ByteString
hostport -> case (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== ':') ByteString
hostport of
(host :: ByteString
host,"") -> (ByteString
host,"80")
(host :: ByteString
host,port :: ByteString
port) -> (ByteString
host, ByteString -> ByteString
BS.tail ByteString
port)