0 | module Node.HTTP2.CreateServer
3 | import Node.HTTP2.Module
4 | import Node.Internal.Support
5 | import public Node.Net.CreateServer
13 | %foreign "node:lambda: (http2) => http2.constants.PADDING_STRATEGY_NONE"
14 | ffi_paddingStrategy_None : {auto http : HTTP2Module} -> Node PaddingStrategy
16 | %foreign "node:lambda: (http2) => http2.constants.PADDING_STRATEGY_MAX"
17 | ffi_paddingStrategy_Max : {auto http : HTTP2Module} -> Node PaddingStrategy
19 | %foreign "node:lambda: (http2) => http2.constants.PADDING_STRATEGY_ALIGNED"
20 | ffi_paddingStrategy_Aligned : {auto http : HTTP2Module} -> Node PaddingStrategy
23 | convertPaddingStrategy : {auto http : HTTP2Module} -> PaddingStrategy -> Node PaddingStrategy
24 | convertPaddingStrategy = \case
25 | None => ffi_paddingStrategy_None
26 | Max => ffi_paddingStrategy_Max
27 | Aligned => ffi_paddingStrategy_Aligned
30 | record Settings where
31 | constructor MkSettings
32 | headerTableSize: Int
34 | initialWindowSize: Int
36 | maxConcurrentStreams: Double
37 | maxHeaderListSize: Int
38 | enableConnectProtocol: Bool
41 | defaultSettings : Settings
42 | defaultSettings = MkSettings
43 | { headerTableSize = 4096
45 | , initialWindowSize = 65535
46 | , maxFrameSize = 16384
47 | , maxConcurrentStreams = 4294967295.0
48 | , maxHeaderListSize = 65535
49 | , enableConnectProtocol = False
58 | , maxConcurrentStreams
60 | , enableConnectProtocol
63 | enablePush: _bool(enablePush) && undefined, // -- TODO check why value true not accepted and causing HTTP2 session errrors?
66 | maxConcurrentStreams,
68 | enableConnectProtocol: _bool(enableConnectProtocol)
71 | ffi_convertSettings :
72 | (headerTableSize: Int) ->
73 | (enablePush: Bool) ->
74 | (initialWindowSize: Int) ->
75 | (maxFrameSize: Int) ->
76 | (maxConcurrentStreams: Double) ->
77 | (maxHeaderListSize: Int) ->
78 | (enableConnectProtocol: Bool) ->
82 | convertSettings : Settings -> Node Settings
83 | convertSettings s = ffi_convertSettings
88 | s.maxConcurrentStreams
90 | s.enableConnectProtocol
93 | record Options where
94 | constructor MkOptions
95 | maxDeflateDynamicTableSize: Int
97 | maxSessionMemory: Int
98 | maxHeaderListPairs: Int
99 | maxOutstandingPings: Int
100 | maxSendHeaderBlockLength: Maybe Int
101 | paddingStrategy: PaddingStrategy
102 | peerMaxConcurrentStreams: Int
103 | maxSessionInvalidFrames: Int
104 | maxSessionRejectedStreams: Int
106 | unknownProtocolTimeout: Int
109 | defaultOptions : HTTP2.CreateServer.Options
110 | defaultOptions = MkOptions
111 | { maxDeflateDynamicTableSize = 4096
113 | , maxSessionMemory = 10
114 | , maxHeaderListPairs = 128
115 | , maxOutstandingPings = 10
116 | , maxSendHeaderBlockLength = Nothing
117 | , paddingStrategy = None
118 | , peerMaxConcurrentStreams = 100
119 | , maxSessionInvalidFrames = 1000
120 | , maxSessionRejectedStreams = 100
121 | , settings = defaultSettings
122 | , unknownProtocolTimeout = 10000
127 | ( maxDeflateDynamicTableSize
130 | , maxHeaderListPairs
131 | , maxOutstandingPings
132 | , maxSendHeaderBlockLength
134 | , peerMaxConcurrentStreams
135 | , maxSessionInvalidFrames
136 | , maxSessionRejectedStreams
138 | , unknownProtocolTimeout
139 | ) => _keepDefined({
140 | maxDeflateDynamicTableSize,
143 | maxHeaderListPairs,
144 | maxOutstandingPings,
145 | maxSendHeaderBlockLength: _maybe(maxSendHeaderBlockLength),
147 | peerMaxConcurrentStreams,
148 | maxSessionInvalidFrames,
149 | maxSessionRejectedStreams,
151 | unknownProtocolTimeout
154 | ffi_convertOptions :
155 | (maxDeflateDynamicTableSize: Int) ->
156 | (maxSettings: Int) ->
157 | (maxSessionMemory: Int) ->
158 | (maxHeaderListPairs: Int) ->
159 | (maxOutstandingPings: Int) ->
160 | (maxSendHeaderBlockLength: Maybe Int) ->
161 | (paddingStrategy: Node PaddingStrategy) ->
162 | (peerMaxConcurrentStreams: Int) ->
163 | (maxSessionInvalidFrames: Int ) ->
164 | (maxSessionRejectedStreams: Int) ->
165 | (settings: Node Settings) ->
166 | (unknownProtocolTimeout: Int) ->
167 | Node HTTP2.CreateServer.Options
170 | convertOptions : {auto http : HTTP2Module} -> HTTP2.CreateServer.Options -> Node HTTP2.CreateServer.Options
171 | convertOptions o = ffi_convertOptions
172 | o.maxDeflateDynamicTableSize
175 | o.maxHeaderListPairs
176 | o.maxOutstandingPings
177 | o.maxSendHeaderBlockLength
178 | (convertPaddingStrategy o.paddingStrategy)
179 | o.peerMaxConcurrentStreams
180 | o.maxSessionInvalidFrames
181 | o.maxSessionRejectedStreams
182 | (convertSettings o.settings)
183 | o.unknownProtocolTimeout
188 | record Options where
189 | constructor MkOptions
190 | server: Node.HTTP2.CreateServer.Options
191 | net: Node.Net.CreateServer.Options
194 | defaultOptions : Command.Options
195 | defaultOptions = MkOptions
196 | { server = defaultOptions
197 | , net = defaultOptions
200 | %foreign "node:lambda: (server, net) => ({...net, ...server})"
201 | ffi_convertOptions :
202 | (server : Node HTTP2.CreateServer.Options)
203 | -> (net : Node Net.CreateServer.Options)
204 | -> Node Command.Options
207 | convertOptions : {auto http : HTTP2Module} -> Command.Options -> Node Command.Options
208 | convertOptions o = Command.ffi_convertOptions
209 | (convertOptions o.server)
210 | (convertOptions o.net)