Skip to content
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

[HttpClient] Add ScopingHttpClient::forBaseUri() + tweak MockHttpClient #30843

Merged
merged 1 commit into from Apr 3, 2019

Conversation

Projects
None yet
3 participants
@nicolas-grekas
Copy link
Member

commented Apr 3, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

This allows creating scoped HTTP clients in one line:

$client = ScopingHttpClient::forBaseUri($client, 'http://example.com');

$client now resolves relative URLs using the provided base URI.

If one also adds default options as 3rd argument, these will be applied conditionally when a URL matching the base URI is requested.

This PR also tweaks MockHttpClient to make it return MockResponse on its own when no constructor argument is provided, easing tests a bit.

@nicolas-grekas nicolas-grekas force-pushed the nicolas-grekas:hc-forbaseuri branch from 9ed37b0 to 2b9b8e5 Apr 3, 2019

@fabpot

fabpot approved these changes Apr 3, 2019

@fabpot

This comment has been minimized.

Copy link
Member

commented Apr 3, 2019

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 2b9b8e5 into symfony:master Apr 3, 2019

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Apr 3, 2019

feature #30843 [HttpClient] Add ScopingHttpClient::forBaseUri() + twe…
…ak MockHttpClient (nicolas-grekas)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpClient] Add ScopingHttpClient::forBaseUri() + tweak MockHttpClient

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This allows creating scoped HTTP clients in one line:

```php
$client = ScopingHttpClient::forBaseUri($client, 'http://example.com');
```

`$client` now resolves relative URLs using the provided base URI.

If one also adds default options as 3rd argument, these will be applied conditionally when a URL matching the base URI is requested.

This PR also tweaks `MockHttpClient` to make it return `MockResponse` on its own when no constructor argument is provided, easing tests a bit.

Commits
-------

2b9b8e5 [HttpClient] Add ScopingHttpClient::forBaseUri() + tweak MockHttpClient

@nicolas-grekas nicolas-grekas deleted the nicolas-grekas:hc-forbaseuri branch Apr 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.