@@ -23,6 +23,12 @@ class Curl
23
23
protected $ strict_mode = false ;
24
24
protected $ max_redirects = 10 ;
25
25
26
+ protected $ http_version = NULL ;
27
+ protected $ http_versions = array (
28
+ '1.0 ' => CURL_HTTP_VERSION_1_0 ,
29
+ '1.1 ' => CURL_HTTP_VERSION_1_1
30
+ );
31
+
26
32
/**
27
33
* Initialize class
28
34
* @param array $config
@@ -292,7 +298,11 @@ public function execute($url = ''){
292
298
$ this ->options [CURLOPT_MAXREDIRS ] = $ this ->max_redirects ;
293
299
}
294
300
295
- empty ($ this ->headers ) or $ this ->options [CURLOPT_HTTPHEADER ] = $ this ->headers ;
301
+ (isset ($ this ->options [CURLOPT_HTTPHEADER ]) or empty ($ this ->headers ))
302
+ or $ this ->options [CURLOPT_HTTPHEADER ] = $ this ->headers ;
303
+
304
+ (isset ($ this ->options [CURLOPT_HTTP_VERSION ]) or empty ($ this ->http_version ))
305
+ or $ this ->options [CURLOPT_HTTP_VERSION ] = $ this ->http_version ;
296
306
297
307
if ($ this ->request = curl_init ($ this ->url ) and is_resource ($ this ->request )){
298
308
$ set_options = curl_setopt_array ($ this ->request , $ this ->options );
@@ -384,6 +394,9 @@ protected function _initialize($config){
384
394
isset ($ config ['timeout ' ]) and $ this ->timeout = $ config ['timeout ' ];
385
395
isset ($ config ['strict_mode ' ]) and $ this ->strict_mode = (bool ) $ config ['strict_mode ' ];
386
396
isset ($ config ['max_redirects ' ]) and $ this ->max_redirects = (int ) $ config ['max_redirects ' ];
397
+
398
+ (isset ($ config ['http_version ' ]) and isset ($ this ->http_versions [$ config ['http_version ' ]]))
399
+ and $ this ->http_version = $ this ->http_versions [$ config ['http_version ' ]];
387
400
}
388
401
}
389
402
0 commit comments