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

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Http/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 tests/ZendTest/Http/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 tests/ZendTest/Http/_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;
}