status-im / nim-chronos

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

HTTP client: Allow request connection management. #323

Closed cheatfate closed 1 year ago

cheatfate commented 1 year ago

This is proper fix for issue and replaces https://github.com/status-im/nim-chronos/pull/321. With this fix

  1. NewConnectionAlways global session flag which will create new connection for every HTTP request and close this connection after request's response received.
  2. Added HttpClientRequestFlag.DedicatedConnection flag which will force to create new HTTP connection for this specific request. Note: Connection is not going to be closed.
  3. HttpClientRequestFlag.CloseConnection flag will force HTTP client to send send Connection: close HTTP header with specific HTTP request and it also closes connection after response will be received.

So now, instead of using NewConnectionAlways you can specify both DedicatedConnection and CloseConnection to get equal behavior.