Skip to content

Commit f687a54

Browse files
authored
Merge pull request #34 from sunrise-php/release/v1.4.5
v1.4.5
2 parents fd63989 + 859f1b3 commit f687a54

File tree

4 files changed

+19
-37
lines changed

4 files changed

+19
-37
lines changed

README.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
composer require sunrise/http-client-curl
1616
```
1717

18-
## How to use?
19-
20-
### Sunrise
18+
## QuickStart
2119

2220
```bash
2321
composer require sunrise/http-factory
@@ -35,26 +33,10 @@ $response = $client->sendRequest($request);
3533
// just use PSR-7 response...
3634
```
3735

38-
### Zend Diactoros
39-
40-
```bash
41-
composer require zendframework/zend-diactoros
42-
```
43-
44-
```php
45-
use Sunrise\Http\Client\Curl\Client;
46-
use Zend\Diactoros\RequestFactory;
47-
use Zend\Diactoros\ResponseFactory;
48-
49-
$client = new Client(new ResponseFactory());
50-
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
51-
$response = $client->sendRequest($request);
52-
53-
// just use PSR-7 response...
54-
```
55-
5636
### cURL options
5737

38+
> https://www.php.net/manual/ru/curl.constants.php
39+
5840
```php
5941
$client = new Client(new ResponseFactory(), [
6042
\CURLOPT_AUTOREFERER => true,
@@ -87,8 +69,6 @@ foreach ($responses as $response) {
8769
composer test
8870
```
8971

90-
---
91-
9272
## Useful links
9373

9474
* http://php.net/manual/en/intro.curl.php

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
"fenric",
88
"sunrise",
99
"http",
10-
"http-client",
10+
"client",
1111
"curl",
1212
"psr-2",
1313
"psr-7",
1414
"psr-17",
1515
"psr-18",
16-
"php7",
17-
"php8"
16+
"php-7",
17+
"php-8"
1818
],
1919
"authors": [
2020
{
2121
"name": "Anatoly Fenric",
22-
"email": "[email protected]",
22+
"email": "[email protected]",
2323
"homepage": "https://github.com/fenric"
2424
},
2525
{
@@ -28,6 +28,10 @@
2828
"homepage": "https://github.com/peter279k"
2929
}
3030
],
31+
"provide": {
32+
"psr/http-client-implementation": "1.0",
33+
"php-http/client-implementation": "1.0"
34+
},
3135
"require": {
3236
"php": "^7.1|^8.0",
3337
"ext-curl": "*",
@@ -38,11 +42,7 @@
3842
"require-dev": {
3943
"phpunit/phpunit": "7.5.20|9.5.0",
4044
"sunrise/coding-standard": "1.0.0",
41-
"sunrise/http-factory": "1.1.0"
42-
},
43-
"provide": {
44-
"psr/http-client-implementation": "1.0",
45-
"php-http/client-implementation": "1.0"
45+
"sunrise/http-factory": "2.0.0"
4646
},
4747
"autoload": {
4848
"psr-4": {

phpunit.xml.dist

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
>
36
<coverage>
47
<include>
58
<directory>./src</directory>
69
</include>
710
</coverage>
811
<testsuites>
9-
<testsuite name="sunrise.http.curlClient.testSuite">
12+
<testsuite name="sunrise/http-client-curl">
1013
<directory>./tests/</directory>
1114
</testsuite>
1215
</testsuites>

src/Client.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ private function createResponseFromCurlHandle($curlHandle) : ResponseInterface
208208
$response = $this->responseFactory->createResponse($statusCode);
209209

210210
/** @var float */
211-
$totalTime = curl_getinfo($curlHandle, CURLINFO_TOTAL_TIME);
212-
$response = $response->withAddedHeader('X-Request-Time', sprintf('%.3f ms', $totalTime * 1000));
211+
$requestTime = curl_getinfo($curlHandle, CURLINFO_TOTAL_TIME);
212+
$response = $response->withAddedHeader('X-Request-Time', sprintf('%.3f ms', $requestTime * 1000));
213213

214214
/** @var ?string */
215215
$message = curl_multi_getcontent($curlHandle);
@@ -219,7 +219,6 @@ private function createResponseFromCurlHandle($curlHandle) : ResponseInterface
219219

220220
/** @var int */
221221
$headerSize = curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE);
222-
223222
$header = substr($message, 0, $headerSize);
224223
$response = $this->populateResponseWithHeaderFields($response, $header);
225224

0 commit comments

Comments
 (0)