mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 07:43:26 +00:00
Merge pull request #4527 from hendi/httpclient-close-sockets
make httpclient close opened Socket on error
This commit is contained in:
@@ -423,6 +423,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||
add(headers, extraHeaders)
|
||||
add(headers, "\c\L")
|
||||
var s = newSocket()
|
||||
defer: s.close()
|
||||
if s == nil: raiseOSError(osLastError())
|
||||
var port = net.Port(80)
|
||||
if r.scheme == "https":
|
||||
@@ -444,7 +445,6 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||
s.send(body)
|
||||
|
||||
result = parseResponse(s, httpMethod != "httpHEAD", timeout)
|
||||
s.close()
|
||||
|
||||
proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||
body = "", sslContext = defaultSSLContext, timeout = -1,
|
||||
|
||||
Reference in New Issue
Block a user