1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-23 17:44:02 +01:00

readd default URI for client implementation for BC

This commit is contained in:
Tobias Schultze 2016-06-05 15:14:17 +02:00
parent 812d9fd2c8
commit 566d90d7cd
2 changed files with 11 additions and 4 deletions

View File

@ -104,7 +104,7 @@ class Client implements ClientInterface
return $this->sendAsync($request, $options)->wait();
}
public function requestAsync($method, $uri, array $options = [])
public function requestAsync($method, $uri = '', array $options = [])
{
$options = $this->prepareDefaults($options);
// Remove request modifying parameter because it can be done up-front.
@ -123,7 +123,7 @@ class Client implements ClientInterface
return $this->transfer($request, $options);
}
public function request($method, $uri, array $options = [])
public function request($method, $uri = '', array $options = [])
{
$options[RequestOptions::SYNCHRONOUS] = true;
return $this->requestAsync($method, $uri, $options)->wait();
@ -142,7 +142,7 @@ class Client implements ClientInterface
return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
}
return Psr7\Uri::resolve($config['base_uri'], $uri);
return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
}
/**

View File

@ -87,7 +87,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
public function testCanMergeOnBaseUriWithRequest()
{
$mock = new MockHandler([new Response()]);
$mock = new MockHandler([new Response(), new Response()]);
$client = new Client([
'handler' => $mock,
'base_uri' => 'http://foo.com/bar/'
@ -97,6 +97,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase
'http://foo.com/bar/baz',
(string) $mock->getLastRequest()->getUri()
);
$client->request('GET', new Uri('baz'), ['base_uri' => 'http://example.com/foo/']);
$this->assertEquals(
'http://example.com/foo/baz',
(string) $mock->getLastRequest()->getUri(),
'Can overwrite the base_uri through the request options'
);
}
public function testCanUseRelativeUriWithSend()