Skip to content

Commit

Permalink
Merge pull request #34 from sunrise-php/release/v1.4.5
Browse files Browse the repository at this point in the history
v1.4.5
  • Loading branch information
fenric authored Apr 17, 2022
2 parents fd63989 + 859f1b3 commit f687a54
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
composer require sunrise/http-client-curl
```

## How to use?

### Sunrise
## QuickStart

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

### Zend Diactoros

```bash
composer require zendframework/zend-diactoros
```

```php
use Sunrise\Http\Client\Curl\Client;
use Zend\Diactoros\RequestFactory;
use Zend\Diactoros\ResponseFactory;

$client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

// just use PSR-7 response...
```

### cURL options

> https://www.php.net/manual/ru/curl.constants.php
```php
$client = new Client(new ResponseFactory(), [
\CURLOPT_AUTOREFERER => true,
Expand Down Expand Up @@ -87,8 +69,6 @@ foreach ($responses as $response) {
composer test
```

---

## Useful links

* http://php.net/manual/en/intro.curl.php
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"fenric",
"sunrise",
"http",
"http-client",
"client",
"curl",
"psr-2",
"psr-7",
"psr-17",
"psr-18",
"php7",
"php8"
"php-7",
"php-8"
],
"authors": [
{
"name": "Anatoly Fenric",
"email": "[email protected]",
"email": "[email protected]",
"homepage": "https://github.com/fenric"
},
{
Expand All @@ -28,6 +28,10 @@
"homepage": "https://github.com/peter279k"
}
],
"provide": {
"psr/http-client-implementation": "1.0",
"php-http/client-implementation": "1.0"
},
"require": {
"php": "^7.1|^8.0",
"ext-curl": "*",
Expand All @@ -38,11 +42,7 @@
"require-dev": {
"phpunit/phpunit": "7.5.20|9.5.0",
"sunrise/coding-standard": "1.0.0",
"sunrise/http-factory": "1.1.0"
},
"provide": {
"psr/http-client-implementation": "1.0",
"php-http/client-implementation": "1.0"
"sunrise/http-factory": "2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 5 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="sunrise.http.curlClient.testSuite">
<testsuite name="sunrise/http-client-curl">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
5 changes: 2 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ private function createResponseFromCurlHandle($curlHandle) : ResponseInterface
$response = $this->responseFactory->createResponse($statusCode);

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

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

/** @var int */
$headerSize = curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE);

$header = substr($message, 0, $headerSize);
$response = $this->populateResponseWithHeaderFields($response, $header);

Expand Down

0 comments on commit f687a54

Please sign in to comment.