{-# 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 = HeaderName
"if-unmodified-since"
hStatus :: HeaderName
hStatus :: HeaderName
hStatus = HeaderName
"status"
hXForwardedFor :: HeaderName
hXForwardedFor :: HeaderName
hXForwardedFor = HeaderName
"x-forwarded-for"
hVia :: HeaderName
hVia :: HeaderName
hVia = HeaderName
"via"
hTransferEncoding :: HeaderName
hTransferEncoding :: HeaderName
hTransferEncoding = HeaderName
"transfer-encoding"
hAcceptEncoding :: HeaderName
hAcceptEncoding :: HeaderName
hAcceptEncoding = HeaderName
"accept-encoding"
hostPort :: Request -> (ByteString, ByteString)
hostPort :: Request -> (ByteString, ByteString)
hostPort Request
req = case Request -> Maybe ByteString
requestHeaderHost Request
req of
Maybe ByteString
Nothing -> (ByteString
"Unknown",ByteString
"80")
Just ByteString
hostport -> case (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
':') ByteString
hostport of
(ByteString
host,ByteString
"") -> (ByteString
host,ByteString
"80")
(ByteString
host,ByteString
port) -> (ByteString
host, HasCallStack => ByteString -> ByteString
ByteString -> ByteString
BS.tail ByteString
port)