diff --git a/SparQL/Connection.php b/SparQL/Connection.php index a5fa9af..2ecf31a 100644 --- a/SparQL/Connection.php +++ b/SparQL/Connection.php @@ -2,8 +2,8 @@ namespace SparQL; -use ByJG\Util\CurlException; use ByJG\Util\WebRequest; +use SparQL\Exception; class Connection { @@ -66,6 +66,13 @@ public function alive($timeout = 3) } } + /** + * + * @param string $sparql + * @param int $timeout Timeout in mileseconds + * @return string + * @throws Exception + */ public function dispatchQuery($sparql, $timeout = null) { $url = $this->endpoint . "?query=" . urlencode($sparql); @@ -77,6 +84,10 @@ public function dispatchQuery($sparql, $timeout = null) } $webRequest = new WebRequest($url); + + if (!empty($timeout)) { + $webRequest->setCurlOption(CURLOPT_TIMEOUT_MS, $timeout); + } $output = $webRequest->get();