Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4925' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Aug 19, 2013
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public function setAdapter($adapter)
*/
public function getAdapter()
{
if (! $this->adapter) {
$this->setAdapter($this->config['adapter']);
}

return $this->adapter;
}

Expand Down Expand Up @@ -812,10 +816,7 @@ public function send(Request $request = null)
$this->redirectCounter = 0;
$response = null;

// Make sure the adapter is loaded
if ($this->adapter == null) {
$this->setAdapter($this->config['adapter']);
}
$adapter = $this->getAdapter();

// Send the first request. If redirected, continue.
do {
Expand Down Expand Up @@ -868,7 +869,7 @@ public function send(Request $request = null)
}

// check that adapter supports streaming before using it
if (is_resource($body) && !($this->adapter instanceof Client\Adapter\StreamInterface)) {
if (is_resource($body) && !($adapter instanceof Client\Adapter\StreamInterface)) {
throw new Client\Exception\RuntimeException('Adapter does not support streaming');
}

Expand Down Expand Up @@ -896,7 +897,7 @@ public function send(Request $request = null)
rewind($stream);
}
// cleanup the adapter
$this->adapter->setOutputStream(null);
$adapter->setOutputStream(null);
$response = Response\Stream::fromStream($response, $stream);
$response->setStreamName($this->streamName);
if (!is_string($this->config['outputstream'])) {
Expand Down
10 changes: 10 additions & 0 deletions test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,14 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost()
// because example.org is not a subdomain unter sub.example.org
$this->assertTrue(strpos($client->getLastRawRequest(), $encoded) === false);
}

public function testAdapterAlwaysReachableIfSpecified()
{
$testAdapter = new Test();
$client = new Client('http://www.example.org/', array(
'adapter' => $testAdapter,
));

$this->assertSame($testAdapter, $client->getAdapter());
}
}

0 comments on commit fa8e439

Please sign in to comment.