Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 136a1ec

Browse files
committed
updated script
1 parent 711d9e6 commit 136a1ec

File tree

3 files changed

+296
-28
lines changed

3 files changed

+296
-28
lines changed

‎example.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
ini_set('display_errors', 1);
3+
error_reporting(E_ALL);
4+
25
require './src/Curl.php';
36
require './src/CurlException.php';
47
require './src/CurlResponse.php';
@@ -17,8 +20,10 @@
1720
$res1 = $curl->get('http://example.com');
1821
//echo $res1;
1922
echo '<pre>';
20-
print_r($curl->getInfo());
23+
echo $res1->getProtocolVersion() . PHP_EOL;
24+
echo $res1->getStatusCode() . '' . $res1->getReasonPhrase() . PHP_EOL;
2125
print_r($res1->getHeaders());
26+
print_r($curl->getInfo());
2227
echo '</pre>';
2328

2429

‎src/Curl.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Curl
2828
protected $strict_mode = false;
2929
protected $max_redirects = 10;
3030

31-
protected $http_version = NULL;
31+
protected $http_version = CURL_HTTP_VERSION_1_1;
3232
protected $http_versions = array(
3333
'1.0' => CURL_HTTP_VERSION_1_0,
3434
'1.1' => CURL_HTTP_VERSION_1_1
@@ -310,7 +310,7 @@ public function execute($url = '') {
310310
}
311311

312312
(isset($this->options[CURLOPT_HTTPHEADER]) or empty($this->headers)) or $this->options[CURLOPT_HTTPHEADER] = $this->headers;
313-
(isset($this->options[CURLOPT_HTTP_VERSION])orempty($this->http_version)) or $this->options[CURLOPT_HTTP_VERSION] = $this->http_version;
313+
(isset($this->options[CURLOPT_HTTP_VERSION])) or $this->options[CURLOPT_HTTP_VERSION] = $this->http_version;
314314
isset($this->options[CURLOPT_USERAGENT]) or $this->options[CURLOPT_USERAGENT] = self::USER_AGENT;
315315

316316
if ($this->request = curl_init($this->url) and is_resource($this->request)) {
@@ -335,7 +335,7 @@ public function execute($url = '') {
335335
$headers = substr($response, 0, $this->info['header_size']);
336336
$body = substr($response, $this->info['header_size']);
337337

338-
return new CurlResponse($response, $headers, $body, $this->info['http_code']);
338+
return new CurlResponse($response, $headers, $body, $this->info['http_code'], array_search($this->http_version, $this->http_versions));
339339
}
340340
} else {
341341
$this->clear();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /