status-im / nim-chronos

Chronos - An efficient library for asynchronous programming
https://status-im.github.io/nim-chronos/docs/chronos
Apache License 2.0
352 stars 51 forks source link

Change header size limits #529

Closed fox0430 closed 2 months ago

fox0430 commented 2 months ago

When I received the response with HttpClientRequestRef, I received a Buffer limit reached error. I think the cause is that the header size is too large, but is it possible to change the limit?

let session = HttpSessionRef.new()

# It's actually a different URL.
let address = session.getAddress("https://example.com").get

let client = HttpClientRequestRef.new(session, address, MethodHead)

let response = await client.send
Error: unhandled exception: Could not read response headers, reason: Buffer limit reached [HttpReadError]

I confirmed that Python requests can be received normally.

cheatfate commented 2 months ago

After the fix you can specify custom size of response headers buffer via maxResponseHeadersSize argument.

let session = HttpSessionRef.new()

# It's actually a different URL.
let address = session.getAddress("https://example.com").get

let client = HttpClientRequestRef.new(session, address, MethodHead, maxResponseHeadersSize = 65535))

let response = await client.send
fox0430 commented 2 months ago

Solved. Thank you.