default services conflit ?
This commit is contained in:
46
old.vendor/geocoder-php/common-http/CHANGELOG.md
Normal file
46
old.vendor/geocoder-php/common-http/CHANGELOG.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Change Log
|
||||
|
||||
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
|
||||
|
||||
## 4.4.0
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for PHP 8.0
|
||||
|
||||
### Removed
|
||||
|
||||
- Drop support for PHP 7.2
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrade PHPUnit to version 9
|
||||
|
||||
## 4.3.0
|
||||
|
||||
### Removed
|
||||
|
||||
- Drop support for PHP < 7.2
|
||||
|
||||
## 4.2.0
|
||||
|
||||
## 4.1.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Refactored `AbstractHttpProvider::getUrlContents` to split it up to different functions. We now
|
||||
got `AbstractHttpProvider::getUrlContents`, `AbstractHttpProvider::getRequest` and `AbstractHttpProvider::getParsedResponse`.
|
||||
|
||||
## 4.0.0
|
||||
|
||||
No changes since beta 2.
|
||||
|
||||
## 4.0.0-beta2
|
||||
|
||||
- Removed `AbstractHttpProvider::setMessageFactory`.
|
||||
- Removed `AbstractHttpProvider::getHttpClient`.
|
||||
- Make sure we have a `MessageFactory` in the constructor of `AbstractHttpProvider`.
|
||||
|
||||
## 4.0.0-beta1
|
||||
|
||||
First release of this library.
|
21
old.vendor/geocoder-php/common-http/LICENSE
Normal file
21
old.vendor/geocoder-php/common-http/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 — William Durand <william.durand1@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Geocoder package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Geocoder\Http\Provider;
|
||||
|
||||
use Geocoder\Exception\InvalidCredentials;
|
||||
use Geocoder\Exception\InvalidServerResponse;
|
||||
use Geocoder\Exception\QuotaExceeded;
|
||||
use Geocoder\Provider\AbstractProvider;
|
||||
use Http\Message\MessageFactory;
|
||||
use Http\Discovery\MessageFactoryDiscovery;
|
||||
use Http\Client\HttpClient;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* @author William Durand <william.durand1@gmail.com>
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
abstract class AbstractHttpProvider extends AbstractProvider
|
||||
{
|
||||
/**
|
||||
* @var HttpClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var MessageFactory
|
||||
*/
|
||||
private $messageFactory;
|
||||
|
||||
/**
|
||||
* @param HttpClient $client
|
||||
* @param MessageFactory|null $factory
|
||||
*/
|
||||
public function __construct(HttpClient $client, MessageFactory $factory = null)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->messageFactory = $factory ?: MessageFactoryDiscovery::find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL and return contents. If content is empty, an exception will be thrown.
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidServerResponse
|
||||
*/
|
||||
protected function getUrlContents(string $url): string
|
||||
{
|
||||
$request = $this->getRequest($url);
|
||||
|
||||
return $this->getParsedResponse($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
protected function getRequest(string $url): RequestInterface
|
||||
{
|
||||
return $this->getMessageFactory()->createRequest('GET', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send request and return contents. If content is empty, an exception will be thrown.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidServerResponse
|
||||
*/
|
||||
protected function getParsedResponse(RequestInterface $request): string
|
||||
{
|
||||
$response = $this->getHttpClient()->sendRequest($request);
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
if (401 === $statusCode || 403 === $statusCode) {
|
||||
throw new InvalidCredentials();
|
||||
} elseif (429 === $statusCode) {
|
||||
throw new QuotaExceeded();
|
||||
} elseif ($statusCode >= 300) {
|
||||
throw InvalidServerResponse::create((string) $request->getUri(), $statusCode);
|
||||
}
|
||||
|
||||
$body = (string) $response->getBody();
|
||||
if (empty($body)) {
|
||||
throw InvalidServerResponse::emptyResponse((string) $request->getUri());
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP adapter.
|
||||
*
|
||||
* @return HttpClient
|
||||
*/
|
||||
protected function getHttpClient(): HttpClient
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MessageFactory
|
||||
*/
|
||||
protected function getMessageFactory(): MessageFactory
|
||||
{
|
||||
return $this->messageFactory;
|
||||
}
|
||||
}
|
26
old.vendor/geocoder-php/common-http/Readme.md
Normal file
26
old.vendor/geocoder-php/common-http/Readme.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Common classes for HTTP based Geocoders
|
||||
|
||||
[](http://travis-ci.org/geocoder-php/php-common-http)
|
||||
[](https://packagist.org/packages/geocoder-php/common-http)
|
||||
[](https://packagist.org/packages/geocoder-php/common-http)
|
||||
[](https://packagist.org/packages/geocoder-php/common-http)
|
||||
[](https://scrutinizer-ci.com/g/geocoder-php/php-common-http)
|
||||
[](https://scrutinizer-ci.com/g/geocoder-php/php-common-http)
|
||||
[](LICENSE)
|
||||
|
||||
This package has dependency on HTTP related libraries. Such as the great [HTTPlug](http://httplug.io/) and [PSR7](http://www.php-fig.org/psr/psr-7/).
|
||||
It does contain a an `AbstractHttpProvider`.
|
||||
|
||||
### Install
|
||||
|
||||
In 99% of the cases you do **not** want to install this package directly. You are more likely to install one provider.
|
||||
Have a look at [the documentation](https://github.com/geocoder-php/Geocoder) to see the different providers.
|
||||
|
||||
```bash
|
||||
composer require geocoder-php/common-http
|
||||
```
|
||||
|
||||
### Contribute
|
||||
|
||||
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or
|
||||
report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues).
|
52
old.vendor/geocoder-php/common-http/composer.json
Normal file
52
old.vendor/geocoder-php/common-http/composer.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "geocoder-php/common-http",
|
||||
"type": "library",
|
||||
"description": "Common files for HTTP based Geocoders",
|
||||
"keywords": [
|
||||
"http geocoder"
|
||||
],
|
||||
"homepage": "http://geocoder-php.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"php-http/client-implementation": "^1.0",
|
||||
"php-http/discovery": "^1.6",
|
||||
"php-http/httplug": "^1.0 || ^2.0",
|
||||
"php-http/message-factory": "^1.0.2",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message-implementation": "^1.0",
|
||||
"willdurand/geocoder": "^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nyholm/psr7": "^1.0",
|
||||
"php-http/message": "^1.0",
|
||||
"php-http/mock-client": "^1.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/stopwatch": "~2.5"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Geocoder\\Http\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit",
|
||||
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user