mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 09:51:36 +03:00
38 lines
970 B
Haskell
38 lines
970 B
Haskell
-- zuse: +http -----------------------------------------------------------------
|
|
|
|
module Vere.Http where
|
|
|
|
import ClassyPrelude
|
|
import Data.Noun
|
|
|
|
import qualified Data.CaseInsensitive as CI
|
|
import qualified Network.HTTP.Types as HT
|
|
import qualified Network.HTTP.Types.Method as H
|
|
|
|
data Header = Header Text Text
|
|
|
|
type Method = H.StdMethod
|
|
|
|
data Request = Request
|
|
{ method :: Method
|
|
, url :: Text
|
|
, headerList :: [Header]
|
|
, body :: Maybe ByteString
|
|
}
|
|
|
|
data ResponseHeader = ResponseHeader
|
|
{ statusCode :: Int
|
|
, headers :: [Header]
|
|
}
|
|
|
|
data Event = Started ResponseHeader -- [%start hdr (unit octs) ?]
|
|
| Received ByteString -- [%continue [~ octs] %.n]
|
|
| Done -- [%continue ~ %.y]
|
|
| Canceled -- %cancel
|
|
| Failed Text -- %cancel
|
|
|
|
convertHeaders :: [HT.Header] -> [Header]
|
|
convertHeaders = fmap f
|
|
where
|
|
f (k, v) = Header (decodeUtf8 (CI.original k)) (decodeUtf8 v)
|