mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-05 07:03:11 +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,
|
||||
results
|
||||
|
||||
const MaxMessageBodyBytes* = 128 * 1024 * 1024 # 128 MB (JSON encoded)
|
||||
|
||||
type
|
||||
RpcBatchItem* = object
|
||||
meth*: string
|
||||
|
||||
@ -33,9 +33,6 @@ type
|
||||
maxBodySize: int
|
||||
getHeaders: GetJsonRpcRequestHeaders
|
||||
|
||||
const
|
||||
MaxHttpRequestSize = 128 * 1024 * 1024 # maximum size of HTTP body in octets
|
||||
|
||||
{.push gcsafe, raises: [].}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@ -43,7 +40,7 @@ const
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc new(
|
||||
T: type RpcHttpClient, maxBodySize = MaxHttpRequestSize, secure = false,
|
||||
T: type RpcHttpClient, maxBodySize = MaxMessageBodyBytes, secure = false,
|
||||
getHeaders: GetJsonRpcRequestHeaders = nil, flags: HttpClientFlags = {}): T =
|
||||
|
||||
var moreFlags: HttpClientFlags
|
||||
@ -132,7 +129,7 @@ proc callImpl(client: RpcHttpClient, reqBody: string): Future[string] {.async.}
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc newRpcHttpClient*(
|
||||
maxBodySize = MaxHttpRequestSize, secure = false,
|
||||
maxBodySize = MaxMessageBodyBytes, secure = false,
|
||||
getHeaders: GetJsonRpcRequestHeaders = nil,
|
||||
flags: HttpClientFlags = {}): RpcHttpClient =
|
||||
RpcHttpClient.new(maxBodySize, secure, getHeaders, flags)
|
||||
|
||||
@ -84,7 +84,7 @@ proc processData(client: RpcWebSocketClient) {.async.} =
|
||||
let ws = client.transport
|
||||
try:
|
||||
while ws.readyState != ReadyState.Closed:
|
||||
var value = await ws.recvMsg()
|
||||
var value = await ws.recvMsg(MaxMessageBodyBytes)
|
||||
|
||||
if value.len == 0:
|
||||
# transmission ends
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user