1
0
Prechádzať zdrojové kódy

Merge pull request #119 from jaskiratsingh91/master

Added a method to set Connect Timeout.
Jan Oris 5 rokov pred
rodič
commit
906659b224
1 zmenil súbory, kde vykonal 12 pridanie a 1 odobranie
  1. 12 1
      src/Builder.php

+ 12 - 1
src/Builder.php

@@ -13,7 +13,7 @@ class Builder {
         'RETURNTRANSFER'        => true,
         'FAILONERROR'           => false,
         'FOLLOWLOCATION'        => false,
-        'CONNECTTIMEOUT'        => '',
+        'CONNECTTIMEOUT'        => 30,
         'TIMEOUT'               => 30,
         'USERAGENT'             => '',
         'URL'                   => '',
@@ -62,6 +62,17 @@ class Builder {
         return $this->withCurlOption( 'TIMEOUT_MS', ($timeout * 1000) );
     }
 
+    /**
+     * Set the connect timeout
+     *
+     * @param   float $timeout    The connect timeout for the request (in seconds, fractions of a second are okay. Default: 30 seconds)
+     * @return Builder
+     */
+    public function withConnectTimeout($timeout = 30.0)
+    {
+        return $this->withCurlOption( 'CONNECTTIMEOUT_MS', ($timeout * 1000) );
+    }
+
     /**
      * Add GET or POST data to the request
      *