diff options
-rw-r--r-- | lib/pure/httpclient.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 7cae86580..83cf77a1b 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -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 |