Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abb0064

Browse files
committed
[Http] Update egeloen/http-adapter library
1 parent 629f059 commit abb0064

File tree

4 files changed

+75
-12
lines changed

4 files changed

+75
-12
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": ">=5.4.0",
16-
"egeloen/http-adapter": "0.5.*",
16+
"egeloen/http-adapter": "0.7.*",
1717
"igorw/get-in": "~1.0"
1818
},
1919
"require-dev": {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
s:1907:"{
2+
"results" : [
3+
{
4+
"address_components" : [
5+
{
6+
"long_name" : "10",
7+
"short_name" : "10",
8+
"types" : [ "street_number" ]
9+
},
10+
{
11+
"long_name" : "Avenue Gambetta",
12+
"short_name" : "Avenue Gambetta",
13+
"types" : [ "route" ]
14+
},
15+
{
16+
"long_name" : "Paris",
17+
"short_name" : "Paris",
18+
"types" : [ "locality", "political" ]
19+
},
20+
{
21+
"long_name" : "Paris",
22+
"short_name" : "75",
23+
"types" : [ "administrative_area_level_2", "political" ]
24+
},
25+
{
26+
"long_name" : "Île-de-France",
27+
"short_name" : "IDF",
28+
"types" : [ "administrative_area_level_1", "political" ]
29+
},
30+
{
31+
"long_name" : "France",
32+
"short_name" : "FR",
33+
"types" : [ "country", "political" ]
34+
},
35+
{
36+
"long_name" : "75020",
37+
"short_name" : "75020",
38+
"types" : [ "postal_code" ]
39+
}
40+
],
41+
"formatted_address" : "10 Avenue Gambetta, 75020 Paris, France",
42+
"geometry" : {
43+
"location" : {
44+
"lat" : 48.8631013,
45+
"lng" : 2.3888086
46+
},
47+
"location_type" : "ROOFTOP",
48+
"viewport" : {
49+
"northeast" : {
50+
"lat" : 48.8644502802915,
51+
"lng" : 2.390157580291502
52+
},
53+
"southwest" : {
54+
"lat" : 48.8617523197085,
55+
"lng" : 2.387459619708498
56+
}
57+
}
58+
},
59+
"place_id" : "ChIJ4b303vJt5kcRF9AQdh4ZjWc",
60+
"types" : [ "street_address" ]
61+
}
62+
],
63+
"status" : "OK"
64+
}
65+
";

tests/Geocoder/Tests/CachedResponseAdapter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Ivory\HttpAdapter\AbstractHttpAdapter;
66
use Ivory\HttpAdapter\HttpAdapterInterface;
77
use Ivory\HttpAdapter\Message\InternalRequestInterface;
8-
use Ivory\HttpAdapter\Message\Stream\StringStream;
98
use Ivory\HttpAdapter\Message\RequestInterface;
109

1110
class CachedResponseAdapter extends AbstractHttpAdapter
@@ -39,28 +38,27 @@ public function getName()
3938
/**
4039
* {@inheritDoc}
4140
*/
42-
protected function doSend(InternalRequestInterface $internalRequest)
41+
protected function sendInternalRequest(InternalRequestInterface $internalRequest)
4342
{
44-
$url = $internalRequest->getUrl();
43+
$url = (string) $internalRequest->getUri();
4544
if ($this->apiKey) {
4645
$url = str_replace($this->apiKey, '[apikey]', $url);
4746
}
47+
4848
$file = sprintf('%s/%s/%s', realpath(__DIR__ . '/../../'), $this->cacheDir, sha1($url));
4949

5050
if ($this->useCache && is_file($file) && is_readable($file)) {
5151
$content = unserialize(file_get_contents($file));
52-
$body = new StringStream($content);
53-
54-
$response = $this->adapter->getConfiguration()->getMessageFactory()->createResponse(
55-
200, 'OK', RequestInterface::PROTOCOL_VERSION_1_1, [], $body
56-
);
5752

5853
if (!empty($content)) {
59-
return $response;
54+
return $this->adapter
55+
->getConfiguration()
56+
->getMessageFactory()
57+
->createResponse(200, RequestInterface::PROTOCOL_VERSION_1_1, [], $content);
6058
}
6159
}
6260

63-
$response = $this->adapter->get($internalRequest->getUrl());
61+
$response = $this->adapter->get($url);
6462

6563
if ($this->useCache) {
6664
file_put_contents($file, serialize((string) $response->getBody()));

tests/Geocoder/Tests/Provider/AbstractProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getName()
4040
return 'mock_http_adapter';
4141
}
4242

43-
protected function doSend(InternalRequestInterface $internalRequest)
43+
protected function sendInternalRequest(InternalRequestInterface $internalRequest)
4444
{
4545
}
4646
}

0 commit comments

Comments
 (0)