Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 2103114

Browse files
committed
Update package, use Client Tools
1 parent 75ddc71 commit 2103114

16 files changed

+54
-125
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ please be as precise as possible. Here is a little list of required information:
1515

1616
## Security issues
1717

18-
If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org) instead of submitting an issue on Github. This allows us to fix the issue and release a security hotfix without publicly disclosing the vulnerability.
18+
If you discover any security related issues,
19+
please contact us at the [security email address](../../#security) instead of submitting an issue on Github.
20+
This allows us to fix the issue and release a security hotfix without publicly disclosing the vulnerability.
1921

2022

2123
## Feature requests
@@ -28,7 +30,8 @@ easily understood/implement it.
2830

2931
## Sending a Pull Request
3032

31-
If you're here, you are going to fix a bug or implement a feature and you're the best! To do it, first fork the repository, clone it and create a new branch with the following commands:
33+
If you're here, you are going to fix a bug or implement a feature and you're the best!
34+
To do it, first fork the repository, clone it and create a new branch with the following commands:
3235

3336
``` bash
3437
$ git clone git@github.com:your-name/repo-name.git
@@ -41,7 +44,12 @@ Then install the dependencies through [Composer](https://getcomposer.org/):
4144
$ composer install
4245
```
4346

44-
Write code and tests. When you are ready, find the testing command in the [README](README.md) and execute it. (This is usually [PHPUnit](http://phpunit.de/) or [PHPSpec](http://phpspec.net/))
47+
Write code and tests. When you are ready, run the tests.
48+
(This is usually [PHPUnit](http://phpunit.de/) or [PHPSpec](http://phpspec.net/))
49+
50+
``` bash
51+
$ composer test
52+
```
4553

4654
When you are ready with the code, tested it and documented it, you can commit and push it with the following commands:
4755

@@ -50,11 +58,15 @@ $ git commit -m "Feature or bug fix description"
5058
$ git push origin feature-or-bug-fix-description
5159
```
5260

53-
**Note:** Please write your commit messages in the imperative and follow the [guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for clear and concise messages.
61+
**Note:** Please write your commit messages in the imperative and follow the
62+
[guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for clear and concise messages.
5463

5564
Then [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on GitHub.
5665

57-
Please make sure that each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting with the following commands (here, we assume you would like to squash 3 commits in a single one):
66+
Please make sure that each individual commit in your pull request is meaningful.
67+
If you had to make multiple intermediate commits while developing,
68+
please squash them before submitting with the following commands
69+
(here, we assume you would like to squash 3 commits in a single one):
5870

5971
``` bash
6072
$ git rebase -i HEAD~3
@@ -77,4 +89,12 @@ you must follow these rules.
7789

7890
## Semver
7991

80-
We are trying to follow [semver](http://semver.org/). When you are making BC breaking changes, please let us know why you think it is important. In this case, your patch can only be included in the next major version.
92+
We are trying to follow [semver](http://semver.org/). When you are making BC breaking changes,
93+
please let us know why you think it is important.
94+
In this case, your patch can only be included in the next major version.
95+
96+
97+
## Code of Conduct
98+
99+
This project is released with a [Contributor Code of Conduct](CONDUCT.md).
100+
By participating in this project you agree to abide by its terms.

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright (c) 2014-2015 Eric GELOEN <geloen.eric@gmail.com>
2+
Copyright (c) 2015 PHP HTTP Team <team@php-http.org>
23

34
Permission is hereby granted, free of charge, to any person obtaining a copy
45
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guzzle 6 Adapter
1+
# Guzzle 6 HTTP Adapter
22

33
[![Latest Version](https://img.shields.io/github/release/php-http/guzzle6-adapter.svg?style=flat-square)](https://github.com/php-http/guzzle6-adapter/releases)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
@@ -27,7 +27,7 @@ Please see the [official documentation](http://php-http.readthedocs.org/en/lates
2727
## Testing
2828

2929
``` bash
30-
$ phpunit
30+
$ composer test
3131
```
3232

3333

@@ -38,12 +38,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details
3838

3939
## Security
4040

41-
If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org).
42-
43-
44-
## Credits
45-
46-
Thanks to [David de Boer](https://github.com/ddeboer) for implementing this adapter.
41+
If you discover any security related issues, please contact us at [security@httplug.io](mailto:security@httplug.io)
42+
or [security@php-http.org](mailto:security@php-http.org).
4743

4844

4945
## License

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Guzzle 6 HTTP Adapter",
44
"license": "MIT",
55
"keywords": ["guzzle", "http"],
6-
"homepage": "http://php-http.org",
6+
"homepage": "http://httplug.io",
77
"authors": [
88
{
99
"name": "David de Boer",
@@ -17,6 +17,7 @@
1717
"require": {
1818
"php": ">=5.5.0",
1919
"php-http/httplug": "^1.0@dev",
20+
"php-http/client-tools": "^0.1@dev",
2021
"guzzlehttp/guzzle": "^6.0"
2122
},
2223
"require-dev": {

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit colors="true" bootstrap="vendor/autoload.php">
33
<testsuites>
4-
<testsuite name="Guzzle 6 Adapter Test Suite">
4+
<testsuite name="Guzzle 6 HTTP Adapter Test Suite">
55
<directory>tests/</directory>
66
</testsuite>
77
</testsuites>

src/Guzzle6HttpAdapter.php

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,44 @@
11
<?php
22

3-
/**
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
113
namespace Http\Adapter;
124

135
use GuzzleHttp\Client;
146
use GuzzleHttp\ClientInterface;
157
use Http\Client\HttpAsyncClient;
168
use Http\Client\HttpClient;
179
use Http\Client\Promise;
10+
use Http\Client\Tools\HttpClientEmulator;
1811
use Psr\Http\Message\RequestInterface;
1912

2013
/**
14+
* HTTP Adapter for Guzzle 6.
15+
*
2116
* @author David de Boer <david@ddeboer.nl>
2217
*/
2318
class Guzzle6HttpAdapter implements HttpClient, HttpAsyncClient
2419
{
20+
use HttpClientEmulator;
21+
2522
/**
2623
* @var ClientInterface
2724
*/
2825
private $client;
2926

3027
/**
31-
* @param ClientInterface|null $client Guzzle client
28+
* @param ClientInterface|null $client
3229
*/
3330
public function __construct(ClientInterface $client = null)
3431
{
3532
$this->client = $client ?: new Client();
3633
}
3734

38-
/**
39-
* {@inheritdoc}
40-
*/
41-
public function sendRequest(RequestInterface $request)
42-
{
43-
$promise = $this->sendAsyncRequest($request);
44-
$promise->wait();
45-
46-
if ($promise->getState() == Promise::REJECTED) {
47-
throw $promise->getException();
48-
}
49-
50-
return $promise->getResponse();
51-
}
52-
5335
/**
5436
* {@inheritdoc}
5537
*/
5638
public function sendAsyncRequest(RequestInterface $request)
5739
{
58-
return new Guzzle6Promise($this->client->sendAsync($request), $request);
40+
$promise = $this->client->sendAsync($request);
41+
42+
return new Guzzle6Promise($promise, $request);
5943
}
6044
}

src/Guzzle6Promise.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
use Psr\Http\Message\RequestInterface;
1010
use Psr\Http\Message\ResponseInterface;
1111

12+
/**
13+
* Wrapper around Guzzle promises.
14+
*
15+
* @author Joel Wurtz <joel.wurtz@gmail.com>
16+
*/
1217
class Guzzle6Promise implements Promise
1318
{
1419
/**
15-
* @var \GuzzleHttp\Promise\PromiseInterface
20+
* @var PromiseInterface
1621
*/
1722
private $promise;
1823

@@ -36,6 +41,10 @@ class Guzzle6Promise implements Promise
3641
*/
3742
private $request;
3843

44+
/**
45+
* @param PromiseInterface $promise
46+
* @param RequestInterface $request
47+
*/
3948
public function __construct(PromiseInterface $promise, RequestInterface $request)
4049
{
4150
$this->request = $request;
@@ -148,4 +157,3 @@ private function handleException(GuzzleExceptions\GuzzleException $exception, Re
148157
return new HttplugException\TransferException($exception->getMessage(), 0, $exception);
149158
}
150159
}
151-

tests/Guzzle6CurlHttpAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\CurlHandler;

tests/Guzzle6CurlHttpAsyncAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\CurlHandler;

tests/Guzzle6HttpAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Client;

tests/Guzzle6HttpAsyncAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Client;

tests/Guzzle6MultiCurlHttpAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\CurlMultiHandler;

tests/Guzzle6MultiCurlHttpAsyncAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\CurlMultiHandler;

tests/Guzzle6PromiseExceptionTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Exception as GuzzleExceptions;
@@ -65,4 +56,4 @@ public function testGetException()
6556
$outputException = $method->invoke($adapter, new GuzzleExceptions\ServerException('foo', $request), $request);
6657
$this->assertInstanceOf('Http\Client\Exception\RequestException', $outputException, "Guzzle's ServerException with no response should be converted to a RequestException");
6758
}
68-
}
59+
}

tests/Guzzle6StreamHttpAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\StreamHandler;

tests/Guzzle6StreamHttpAsyncAdapterTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Http Adapter package.
5-
*
6-
* (c) Eric GELOEN <geloen.eric@gmail.com>
7-
*
8-
* For the full copyright and license information, please read the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
namespace Http\Adapter\Tests;
134

145
use GuzzleHttp\Handler\StreamHandler;

0 commit comments

Comments
 (0)