From 0b6c3e6732c5c0d5b6613d2fe450c3b7760c0827 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 9 Jun 2018 22:26:16 +0300 Subject: Add support for "--disable-download-timeout" option --- src/wrapper/curl.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/wrapper') 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) -- cgit v1.2.3-70-g09d2