added getSocket proc (#11233)

This commit is contained in:
Boris Shomodjvarac
2019-05-15 16:47:25 +01:00
committed by Andreas Rumpf
parent 7fb256bded
commit de6b2e88d2

View File

@@ -640,6 +640,21 @@ proc close*(client: HttpClient | AsyncHttpClient) =
client.socket.close()
client.connected = false
proc getSocket*(client: HttpClient): Socket =
## Get network socket, useful if you want to find out more details about the connection
##
## this example shows info about local and remote endpoints
##
## .. code-block:: Nim
## if client.connected:
## echo client.getSocket.getLocalAddr
## echo client.getSocket.getPeerAddr
##
return client.socket
proc getSocket*(client: AsyncHttpClient): AsyncSocket =
return client.socket
proc reportProgress(client: HttpClient | AsyncHttpClient,
progress: BiggestInt) {.multisync.} =
client.contentProgress += progress