Export SocketFlags for HTTP client. (#389)

This commit is contained in:
Eugene Kabanov 2023-05-18 10:10:01 +03:00 committed by GitHub
parent 956ae5af55
commit 61d52b1ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import httptable, httpcommon, httpagent, httpbodyrw, multipart
export results, asyncloop, asyncsync, asyncstream, tlsstream, chunkstream, export results, asyncloop, asyncsync, asyncstream, tlsstream, chunkstream,
boundstream, httptable, httpcommon, httpagent, httpbodyrw, multipart, boundstream, httptable, httpcommon, httpagent, httpbodyrw, multipart,
httputils httputils
export SocketFlags
const const
HttpMaxHeadersSize* = 8192 HttpMaxHeadersSize* = 8192
@ -122,6 +123,7 @@ type
connectionBufferSize*: int connectionBufferSize*: int
maxConnections*: int maxConnections*: int
connectionsCount*: int connectionsCount*: int
socketFlags*: set[SocketFlags]
flags*: HttpClientFlags flags*: HttpClientFlags
HttpAddress* = object HttpAddress* = object
@ -345,7 +347,8 @@ proc new*(t: typedesc[HttpSessionRef],
connectionBufferSize = DefaultStreamBufferSize, connectionBufferSize = DefaultStreamBufferSize,
maxConnections = -1, maxConnections = -1,
idleTimeout = HttpConnectionIdleTimeout, idleTimeout = HttpConnectionIdleTimeout,
idlePeriod = HttpConnectionCheckPeriod): HttpSessionRef {. idlePeriod = HttpConnectionCheckPeriod,
socketFlags: set[SocketFlags] = {}): HttpSessionRef {.
raises: [Defect] .} = raises: [Defect] .} =
## Create new HTTP session object. ## Create new HTTP session object.
## ##
@ -365,6 +368,7 @@ proc new*(t: typedesc[HttpSessionRef],
idleTimeout: idleTimeout, idleTimeout: idleTimeout,
idlePeriod: idlePeriod, idlePeriod: idlePeriod,
connections: initTable[string, seq[HttpClientConnectionRef]](), connections: initTable[string, seq[HttpClientConnectionRef]](),
socketFlags: socketFlags
) )
res.watcherFut = res.watcherFut =
if HttpClientFlag.Http11Pipeline in flags: if HttpClientFlag.Http11Pipeline in flags:
@ -619,7 +623,8 @@ proc connect(session: HttpSessionRef,
for address in ha.addresses: for address in ha.addresses:
let transp = let transp =
try: try:
await connect(address, bufferSize = session.connectionBufferSize) await connect(address, bufferSize = session.connectionBufferSize,
flags = session.socketFlags)
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError: except CatchableError: