Merge pull request #4527 from hendi/httpclient-close-sockets
make httpclient close opened Socket on error
This commit is contained in:
commit
d7a1abd5f7
1 changed files with 1 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue