A testing-purposes adapter.
Should be used to test all components that rely on Zend_Http_Client,
without actually performing an HTTP request. You should instantiate this
object manually, and then set it as the client's adapter. Then, you can
set the expected response using the setResponse() method.
category |
Zend |
package |
Zend_Http |
subpackage |
Client_Adapter |
copyright |
Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license |
New BSD License |
Methods
Adapter constructor, currently empty. Config is set using setConfig()
__construct()
Add another response to the response buffer.
addResponse($response)
Close the connection (dummy)
close()
inherited_from |
\Zend_Http_Client_Adapter_Interface::close() |
Connect to the remote server
connect(string $host, integer $port = 80
, boolean $secure = false
)
inherited_from |
\Zend_Http_Client_Adapter_Interface::connect() |
Parameters
$host
string
$port
integer
$secure
boolean
Exceptions
\Zend_Http_Client_Adapter_Exception |
|
Retrieve the array of all configuration options
getConfig() : array
Return the response set in $this->setResponse()
read() : string
inherited_from |
\Zend_Http_Client_Adapter_Interface::read() |
Returns
string
Set the configuration array for the adapter
setConfig(array $config = array()
)
inherited_from |
\Zend_Http_Client_Adapter_Interface::setConfig() |
Parameters
$config
Set the nextRequestWillFail flag
setNextRequestWillFail(boolean $flag) : \Zend_Http_Client_Adapter_Test
Parameters
$flag
boolean
Returns
\Zend_Http_Client_Adapter_Test
Set the HTTP response(s) to be returned by this adapter
setResponse(\Zend_Http_Response|array|string $response)
Parameters
$response
\Zend_Http_Response
array
string
Sets the position of the response buffer. Selects which
response will be returned on the next call to read().
setResponseIndex(integer $index)
Parameters
$index
integer
Send request to the remote server
write(string $method, \Zend_Uri_Http $uri, string $http_ver = '1.1'
, array $headers = array()
, string $body = ''
) : string
inherited_from |
\Zend_Http_Client_Adapter_Interface::write() |
Parameters
$method
string
$uri
\Zend_Uri_Http
$http_ver
string
$headers
array
$body
string
Returns
string
Request as string
Properties
Wether or not the next request will fail with an exception
$_nextRequestWillFail : boolean
Parameters array
$config : array
Current position in the response buffer
$responseIndex : integer
Buffer of responses to be returned by the read() method. Can be
set using setResponse() and addResponse().
$responses : array
Default
array("HTTP/1.1 400 Bad Request\r\n\r\n")