module Network.HTTP2.Arch.EncodeFrame where

import Network.HTTP2.Frame

import Imports

----------------------------------------------------------------

goawayFrame :: StreamId -> ErrorCodeId -> ByteString -> ByteString
goawayFrame :: StreamId -> ErrorCodeId -> ByteString -> ByteString
goawayFrame StreamId
sid ErrorCodeId
etype ByteString
debugmsg = EncodeInfo -> FramePayload -> ByteString
encodeFrame EncodeInfo
einfo FramePayload
frame
  where
    einfo :: EncodeInfo
einfo = (FrameFlags -> FrameFlags) -> StreamId -> EncodeInfo
encodeInfo FrameFlags -> FrameFlags
forall a. a -> a
id StreamId
0
    frame :: FramePayload
frame = StreamId -> ErrorCodeId -> ByteString -> FramePayload
GoAwayFrame StreamId
sid ErrorCodeId
etype ByteString
debugmsg

resetFrame :: ErrorCodeId -> StreamId -> ByteString
resetFrame :: ErrorCodeId -> StreamId -> ByteString
resetFrame ErrorCodeId
etype StreamId
sid = EncodeInfo -> FramePayload -> ByteString
encodeFrame EncodeInfo
einfo FramePayload
frame
  where
    einfo :: EncodeInfo
einfo = (FrameFlags -> FrameFlags) -> StreamId -> EncodeInfo
encodeInfo FrameFlags -> FrameFlags
forall a. a -> a
id StreamId
sid
    frame :: FramePayload
frame = ErrorCodeId -> FramePayload
RSTStreamFrame ErrorCodeId
etype

settingsFrame :: (FrameFlags -> FrameFlags) -> SettingsList -> ByteString
settingsFrame :: (FrameFlags -> FrameFlags) -> SettingsList -> ByteString
settingsFrame FrameFlags -> FrameFlags
func SettingsList
alist = EncodeInfo -> FramePayload -> ByteString
encodeFrame EncodeInfo
einfo (FramePayload -> ByteString) -> FramePayload -> ByteString
forall a b. (a -> b) -> a -> b
$ SettingsList -> FramePayload
SettingsFrame SettingsList
alist
  where
    einfo :: EncodeInfo
einfo = (FrameFlags -> FrameFlags) -> StreamId -> EncodeInfo
encodeInfo FrameFlags -> FrameFlags
func StreamId
0

pingFrame :: ByteString -> ByteString
pingFrame :: ByteString -> ByteString
pingFrame ByteString
bs = EncodeInfo -> FramePayload -> ByteString
encodeFrame EncodeInfo
einfo (FramePayload -> ByteString) -> FramePayload -> ByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> FramePayload
PingFrame ByteString
bs
  where
    einfo :: EncodeInfo
einfo = (FrameFlags -> FrameFlags) -> StreamId -> EncodeInfo
encodeInfo FrameFlags -> FrameFlags
setAck StreamId
0

windowUpdateFrame :: StreamId -> WindowSize -> ByteString
windowUpdateFrame :: StreamId -> StreamId -> ByteString
windowUpdateFrame StreamId
sid StreamId
winsiz = EncodeInfo -> FramePayload -> ByteString
encodeFrame EncodeInfo
einfo (FramePayload -> ByteString) -> FramePayload -> ByteString
forall a b. (a -> b) -> a -> b
$ StreamId -> FramePayload
WindowUpdateFrame StreamId
winsiz
  where
    einfo :: EncodeInfo
einfo = (FrameFlags -> FrameFlags) -> StreamId -> EncodeInfo
encodeInfo FrameFlags -> FrameFlags
forall a. a -> a
id StreamId
sid