aboutsummaryrefslogtreecommitdiff
path: root/src/wrapper
diff options
context:
space:
mode:
authorkitsunyan2018-06-09 19:26:16 +0000
committerkitsunyan2018-06-09 19:26:16 +0000
commit0b6c3e6732c5c0d5b6613d2fe450c3b7760c0827 (patch)
tree72fac7f0d47d7ef1683bc2be639fb3cea524ee17 /src/wrapper
parent56e82963b465116af32231aa531e8f6344826eab (diff)
Add support for "--disable-download-timeout" option
Diffstat (limited to 'src/wrapper')
-rw-r--r--src/wrapper/curl.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wrapper/curl.nim b/src/wrapper/curl.nim
index 5f3e814..98d6880 100644
--- a/src/wrapper/curl.nim
+++ b/src/wrapper/curl.nim
@@ -99,19 +99,20 @@ template withCurl*(instance: untyped, body: untyped): untyped =
else:
raise newException(CurlError, tr"failed to perform request")
- proc performInternal(url: string): seq[char] =
+ proc performInternal(url: string, useTimeout: bool): seq[char] =
+ let timeoutMs = if useTimeout: 15000 else: 0
raiseError(handle.setOption(CurlOption.followLocation, (clong) 1))
raiseError(handle.setOption(CurlOption.noSignal, (clong) 1))
- raiseError(handle.setOption(CurlOption.timeoutMs, (clong) 15000))
- raiseError(handle.setOption(CurlOption.connectTimeoutMs, (clong) 15000))
+ raiseError(handle.setOption(CurlOption.timeoutMs, (clong) timeoutMs))
+ raiseError(handle.setOption(CurlOption.connectTimeoutMs, (clong) timeoutMs))
raiseError(handle.setOption(CurlOption.url, url))
raiseError(handle.setOption(CurlOption.writeFunction, cast[pointer](curlWriteMemory)))
raiseError(handle.setOption(CurlOption.writeData, instance))
raiseError(handle.perform())
instance.data
- proc performString(url: string): string =
- let data = performInternal(url)
+ proc performString(url: string, useTimeout: bool): string =
+ let data = performInternal(url, useTimeout)
var str = newStringOfCap(data.len)
for c in data:
str.add(c)