Skip to content

Terminology #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Sep 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d2d1b24
Update composer
sagikazarmark Aug 23, 2015
c060d2e
Update README
sagikazarmark Aug 23, 2015
b6cce0f
Rename HttpAdapter to PsrHttpClient
sagikazarmark Aug 23, 2015
029b733
Rename exceptions
sagikazarmark Aug 23, 2015
8b582af
Client should always throw a simple Exception
sagikazarmark Aug 23, 2015
2a26ef0
Remove shortcut method from exception
sagikazarmark Aug 23, 2015
9f434a4
Play with exceptions
sagikazarmark Aug 23, 2015
688f737
Adds HttpClient
sagikazarmark Aug 23, 2015
6a04619
Give better explanation
sagikazarmark Aug 25, 2015
7ecdd59
Add Body interface and implementations
sagikazarmark Aug 26, 2015
19453a4
Merge pull request #42 from php-http/body
sagikazarmark Aug 26, 2015
d9b9043
Fix body related issues
sagikazarmark Aug 27, 2015
b7aba28
Add testing
sagikazarmark Aug 26, 2015
fb19763
Merge pull request #44 from php-http/tests
sagikazarmark Aug 27, 2015
81ea240
Refactor exceptions, add new exceptions, make batch exception final, …
sagikazarmark Aug 26, 2015
e341e16
Add factory methods
sagikazarmark Aug 26, 2015
6dc544b
Add tests for exceptions, fix some mistakes
sagikazarmark Aug 27, 2015
916048d
Fix indentation
sagikazarmark Sep 19, 2015
c54bbf1
Fix exception descriptions
sagikazarmark Sep 19, 2015
895872d
Fix PSR-2 incompatibilities
sagikazarmark Sep 19, 2015
a943f2d
Fix logical issues in code
sagikazarmark Sep 19, 2015
c630ab7
Make request property final
sagikazarmark Sep 21, 2015
4174e1a
Make exceptions final
sagikazarmark Sep 21, 2015
df3bdbb
Revert NetworkException: not final
sagikazarmark Sep 21, 2015
58a3d52
Remove responses from BatchException
sagikazarmark Sep 21, 2015
67baf37
Merge pull request #43 from php-http/exceptions
sagikazarmark Sep 21, 2015
cf38fcc
Add BatchResult
sagikazarmark Sep 21, 2015
8d6abb2
Remove decision maker method
sagikazarmark Sep 22, 2015
e6acb53
Fix description
sagikazarmark Sep 22, 2015
f68ad2c
Move exceptions to BatchException
sagikazarmark Sep 22, 2015
437a2e1
Improve tests
sagikazarmark Sep 22, 2015
3950679
Improve documentation
sagikazarmark Sep 22, 2015
9cb62d9
Add tests
sagikazarmark Sep 22, 2015
708c447
Remove hasExceptions from BatchException
sagikazarmark Sep 22, 2015
3eb7cbc
Throw invalid argument exception if request is not found
sagikazarmark Sep 22, 2015
44e8c01
Add custom UnexpectedValueException, throw exception when request is …
sagikazarmark Sep 22, 2015
2e16453
Merge pull request #48 from php-http/batch_response
sagikazarmark Sep 22, 2015
2627a80
Add sendRequests method as a trait
joelwurtz Sep 23, 2015
26c9257
Merge pull request #54 from joelwurtz/feature/batch-requests
sagikazarmark Sep 23, 2015
4248e36
Make custom SPL exception extensions final
sagikazarmark Sep 25, 2015
443ec9f
Merge pull request #57 from php-http/spl_exceptions
sagikazarmark Sep 25, 2015
2ae36c5
Remove HTTP server from testing
sagikazarmark Sep 25, 2015
603d083
Use new travis infrastructure
sagikazarmark Sep 25, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
spec/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
CONTRIBUTING.md export-ignore
phpspec.yml.ci export-ignore
phpspec.yml.dist export-ignore
11 changes: 11 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
filter:
paths: [src/*]
checks:
php:
code_rating: true
duplication: true
tools:
external_code_coverage: true
php_code_sniffer:
config:
standard: "PSR2"
38 changes: 38 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
language: php

sudo: false

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

env:
global:
- TEST_COMMAND="composer test"

matrix:
allow_failures:
- php: 7.0
fast_finish: true
include:
- php: 5.4
env:
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- COVERAGE=true
- TEST_COMMAND="composer test-ci"

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction

script:
- $TEST_COMMAND

after_success:
- if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
# HTTP Adapter
# HTTP Client

[![Latest Version](https://img.shields.io/github/release/php-http/adapter.svg?style=flat-square)](https://github.com/php-http/adapter/releases)
[![Latest Version](https://img.shields.io/github/release/php-http/client.svg?style=flat-square)](https://github.com/php-http/client/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/adapter.svg?style=flat-square)](https://packagist.org/packages/php-http/adapter)
[![Build Status](https://img.shields.io/travis/php-http/client.svg?style=flat-square)](https://travis-ci.org/php-http/client)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client)
[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client)
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/client.svg?style=flat-square)](https://packagist.org/packages/php-http/client)

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/php-http/adapter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**HTTP Adapter interfaces.**
**HTTP Client interfaces.**


## Install

Via Composer

``` bash
$ composer require php-http/adapter
$ composer require php-http/client
```


## Usage

This is the contract package for HTTP Adapter. It should be used when implementing a custom HTTP Adapter or to rely on a stable version of interfaces.
This is the contract package for HTTP Client interfacess. PSR-7 does not contain Client interfaces which is fine. However there is still need for HTTP Client interoperability.

There is also a virtual package which is versioned together with this contract package: [php-http/adapter-implementation](https://packagist.org/providers/php-http/adapter-implementation).
These interfaces are mostly used to create adapter packages around existing HTTP Client implementations.

There is also a virtual package which is versioned together with this contract package: [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation).


## Documentation

Please see the [official documentation](http://php-http.readthedocs.org/en/latest/).


## Testing

``` bash
$ composer test
```


## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Expand Down
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "php-http/adapter",
"description": "HTTP Adapter interfaces",
"name": "php-http/client",
"description": "HTTP Client interfaces",
"license": "MIT",
"keywords": ["http", "adapter"],
"keywords": ["http", "client"],
"homepage": "http://php-http.org",
"authors": [
{
Expand All @@ -18,11 +18,19 @@
"php": ">=5.4",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpspec/phpspec": "^2.2",
"henrikbjorn/phpspec-code-coverage" : "^1.0"
},
"autoload": {
"psr-4": {
"Http\\Adapter\\": "src/"
"Http\\Client\\": "src/"
}
},
"scripts": {
"test": "vendor/bin/phpspec run",
"test-ci": "vendor/bin/phpspec run -c phpspec.yml.ci"
},
"extra": {
"branch-alias": {
"dev-master": "0.2-dev"
Expand Down
10 changes: 10 additions & 0 deletions phpspec.yml.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
suites:
client_suite:
namespace: Http\Client
psr4_prefix: Http\Client
formatter.name: pretty
extensions:
- PhpSpec\Extension\CodeCoverageExtension
code_coverage:
format: clover
output: build/coverage.xml
5 changes: 5 additions & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
suites:
client_suite:
namespace: Http\Client
psr4_prefix: Http\Client
formatter.name: pretty
44 changes: 44 additions & 0 deletions spec/BatchResultSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace spec\Http\Client;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use PhpSpec\ObjectBehavior;

class BatchResultSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\BatchResult');
}

function it_is_immutable(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

$this->getResponses()->shouldReturn([]);
$new->shouldHaveType('Http\Client\BatchResult');
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

$this->hasResponses()->shouldReturn(false);
$this->getResponses()->shouldReturn([]);
$new->hasResponses()->shouldReturn(true);
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

$this->shouldThrow('Http\Client\Exception\UnexpectedValueException')->duringGetResponseFor($request);
$this->hasResponseFor($request)->shouldReturn(false);
$new->getResponseFor($request)->shouldReturn($response);
$new->hasResponseFor($request)->shouldReturn(true);
}
}
44 changes: 44 additions & 0 deletions spec/Body/CombinedMultipartSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace spec\Http\Client\Body;

use PhpSpec\ObjectBehavior;

class CombinedMultipartSpec extends ObjectBehavior
{
protected $file;

function let()
{
$this->file = tempnam(sys_get_temp_dir(), 'multipart');

$this->beConstructedWith(['data' => 1], ['file' => $this->file], 'boundary');
}

function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Body\CombinedMultipart');
}

function it_is_body()
{
$this->shouldImplement('Http\Client\Body');
}

function it_is_multipart()
{
$this->shouldHaveType('Http\Client\Body\Multipart');
}

function it_has_content_header()
{
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
}

function it_is_streamable()
{
$body = sprintf("--boundary\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n1\r\n--boundary\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n\r\n\r\n", basename($this->file));

$this->toStreamable()->shouldReturn($body);
}
}
44 changes: 44 additions & 0 deletions spec/Body/FilesSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace spec\Http\Client\Body;

use PhpSpec\ObjectBehavior;

class FilesSpec extends ObjectBehavior
{
protected $file;

function let()
{
$this->file = tempnam(sys_get_temp_dir(), 'multipart');

$this->beConstructedWith(['file' => $this->file], 'boundary');
}

function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Body\Files');
}

function it_is_body()
{
$this->shouldImplement('Http\Client\Body');
}

function it_is_multipart()
{
$this->shouldHaveType('Http\Client\Body\Multipart');
}

function it_has_content_header()
{
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
}

function it_is_streamable()
{
$body = sprintf("--boundary\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n\r\n\r\n", basename($this->file));

$this->toStreamable()->shouldReturn($body);
}
}
40 changes: 40 additions & 0 deletions spec/Body/MultipartDataSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace spec\Http\Client\Body;

use PhpSpec\ObjectBehavior;

class MultipartDataSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(['data' => 1], 'boundary');
}

function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Body\MultipartData');
}

function it_is_body()
{
$this->shouldImplement('Http\Client\Body');
}

function it_is_multipart()
{
$this->shouldHaveType('Http\Client\Body\Multipart');
}

function it_has_content_header()
{
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
}

function it_is_streamable()
{
$body = "--boundary\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n1\r\n";

$this->toStreamable()->shouldReturn($body);
}
}
33 changes: 33 additions & 0 deletions spec/Body/UrlencodedDataSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace spec\Http\Client\Body;

use PhpSpec\ObjectBehavior;

class UrlencodedDataSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(['data1' => 1, 'data2' => 2]);
}

function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Body\UrlencodedData');
}

function it_is_body()
{
$this->shouldImplement('Http\Client\Body');
}

function it_has_content_header()
{
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'application/x-www-form-urlencoded']);
}

function it_is_streamable()
{
$this->toStreamable()->shouldReturn('data1=1&data2=2');
}
}
Loading