From f8fb7268ff4715ec90c8ba5381929754c19fa815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Fri, 19 Jun 2015 15:00:56 +0200 Subject: [PATCH] Allow to specify a timeout --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 64af207..78e436b 100644 --- a/index.js +++ b/index.js @@ -45,6 +45,12 @@ function questor(uri, options) { })); }); + if ('timeout' in options) { + request.setTimeout(options.timeout, function () { + request.abort(); + }); + } + request.on('error', reject); request.end(requestBody);