mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-06-06 01:39:26 +00:00
align maximum body size between Websock and HTTP transports (#211)
HTTP has a 128 MB limit, while websock uses the library default (20 MB). Align both to 128 MB. This should be enough for an Ethereum `getPayload` with 6 blobs, all hex encoded binary + JSON overhead.
This commit is contained in:
parent
9c65df3053
commit
8682bb6c85
@ -28,6 +28,8 @@ export
|
|||||||
ResponseBatchRx,
|
ResponseBatchRx,
|
||||||
results
|
results
|
||||||
|
|
||||||
|
const MaxMessageBodyBytes* = 128 * 1024 * 1024 # 128 MB (JSON encoded)
|
||||||
|
|
||||||
type
|
type
|
||||||
RpcBatchItem* = object
|
RpcBatchItem* = object
|
||||||
meth*: string
|
meth*: string
|
||||||
|
|||||||
@ -33,9 +33,6 @@ type
|
|||||||
maxBodySize: int
|
maxBodySize: int
|
||||||
getHeaders: GetJsonRpcRequestHeaders
|
getHeaders: GetJsonRpcRequestHeaders
|
||||||
|
|
||||||
const
|
|
||||||
MaxHttpRequestSize = 128 * 1024 * 1024 # maximum size of HTTP body in octets
|
|
||||||
|
|
||||||
{.push gcsafe, raises: [].}
|
{.push gcsafe, raises: [].}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -43,7 +40,7 @@ const
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc new(
|
proc new(
|
||||||
T: type RpcHttpClient, maxBodySize = MaxHttpRequestSize, secure = false,
|
T: type RpcHttpClient, maxBodySize = MaxMessageBodyBytes, secure = false,
|
||||||
getHeaders: GetJsonRpcRequestHeaders = nil, flags: HttpClientFlags = {}): T =
|
getHeaders: GetJsonRpcRequestHeaders = nil, flags: HttpClientFlags = {}): T =
|
||||||
|
|
||||||
var moreFlags: HttpClientFlags
|
var moreFlags: HttpClientFlags
|
||||||
@ -132,7 +129,7 @@ proc callImpl(client: RpcHttpClient, reqBody: string): Future[string] {.async.}
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc newRpcHttpClient*(
|
proc newRpcHttpClient*(
|
||||||
maxBodySize = MaxHttpRequestSize, secure = false,
|
maxBodySize = MaxMessageBodyBytes, secure = false,
|
||||||
getHeaders: GetJsonRpcRequestHeaders = nil,
|
getHeaders: GetJsonRpcRequestHeaders = nil,
|
||||||
flags: HttpClientFlags = {}): RpcHttpClient =
|
flags: HttpClientFlags = {}): RpcHttpClient =
|
||||||
RpcHttpClient.new(maxBodySize, secure, getHeaders, flags)
|
RpcHttpClient.new(maxBodySize, secure, getHeaders, flags)
|
||||||
|
|||||||
@ -84,7 +84,7 @@ proc processData(client: RpcWebSocketClient) {.async.} =
|
|||||||
let ws = client.transport
|
let ws = client.transport
|
||||||
try:
|
try:
|
||||||
while ws.readyState != ReadyState.Closed:
|
while ws.readyState != ReadyState.Closed:
|
||||||
var value = await ws.recvMsg()
|
var value = await ws.recvMsg(MaxMessageBodyBytes)
|
||||||
|
|
||||||
if value.len == 0:
|
if value.len == 0:
|
||||||
# transmission ends
|
# transmission ends
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user