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/5068' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 4, 2013
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ public function send(Request $request = null)
$response->setCleanup(true);
}
} else {
$response = Response::fromString($response);
$response = $this->getResponse()->fromString($response);
}

// Get the cookies from response (if any)
Expand Down
44 changes: 44 additions & 0 deletions test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,48 @@ public function testAdapterAlwaysReachableIfSpecified()

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

/**
* Custom response object is set but still invalid code coming back
* @expectedException Zend\Http\Exception\InvalidArgumentException
*/
public function testUsageOfCustomResponseInvalidCode()
{
require_once(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR .'_files' . DIRECTORY_SEPARATOR . 'CustomResponse.php');
$testAdapter = new Test();
$testAdapter->setResponse(
"HTTP/1.1 496 CustomResponse\r\n\r\n"
. "Whatever content"
);

$client = new Client('http://www.example.org/', array(
'adapter' => $testAdapter,
));
$client->setResponse(new CustomResponse());
$response = $client->send();
}

/**
* Custom response object is set with defined status code 497.
* Should not throw an exception.
*/
public function testUsageOfCustomResponseCustomCode()
{
require_once(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR .'_files' . DIRECTORY_SEPARATOR . 'CustomResponse.php');
$testAdapter = new Test();
$testAdapter->setResponse(
"HTTP/1.1 497 CustomResponse\r\n\r\n"
. "Whatever content"
);

$client = new Client('http://www.example.org/', array(
'adapter' => $testAdapter,
));
$client->setResponse(new CustomResponse());
$response = $client->send();

$this->assertInstanceOf('ZendTest\Http\CustomResponse', $response);
$this->assertEquals(497, $response->getStatusCode());
$this->assertEquals('Whatever content', $response->getContent());
}
}
7 changes: 7 additions & 0 deletions test/_files/CustomResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace ZendTest\Http;

class CustomResponse extends \Zend\Http\Response
{
const STATUS_CODE_497 = 497;
}

0 comments on commit fdedc25

Please sign in to comment.