PHP Class SimpleHttpRequest, simpletest

@package SimpleTest
显示文件 Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method Description
__construct ( SimpleRoute $route, SimpleFormEncoding $encoding ) Builds the socket request from the different pieces.
addHeaderLine ( string $header_line ) Adds a header line to the request.
fetch ( integer $timeout ) : SimpleHttpResponse Dispatches the content to the route's socket.
getHeaders ( ) : array Get the headers to be sent with the request.
readCookiesFromJar ( SimpleCookieJar $jar, SimpleUrl $url ) Reads all the relevant cookies from the cookie jar.

Protected Methods

Method Description
createResponse ( SimpleSocket $socket ) : SimpleHttpResponse Wraps the socket in a response parser.
dispatchRequest ( SimpleSocket $socket, SimpleFormEncoding $encoding ) Sends the headers.

Method Details

__construct() public method

These include proxy information, URL, cookies, headers, request method and choice of encoding.
public __construct ( SimpleRoute $route, SimpleFormEncoding $encoding )
$route SimpleRoute Request route.
$encoding SimpleFormEncoding Content to send with request.

addHeaderLine() public method

@param string $header_line Text of full header line.
public addHeaderLine ( string $header_line )
$header_line string

createResponse() protected method

Wraps the socket in a response parser.
protected createResponse ( SimpleSocket $socket ) : SimpleHttpResponse
$socket SimpleSocket Responding socket.
return SimpleHttpResponse Parsed response object.

dispatchRequest() protected method

Sends the headers.
protected dispatchRequest ( SimpleSocket $socket, SimpleFormEncoding $encoding )
$socket SimpleSocket Open socket.
$encoding SimpleFormEncoding Content to send with request.

fetch() public method

Dispatches the content to the route's socket.
public fetch ( integer $timeout ) : SimpleHttpResponse
$timeout integer Connection timeout.
return SimpleHttpResponse A response which may only have an error, but hopefully has a complete web page.

getHeaders() public method

Get the headers to be sent with the request.
public getHeaders ( ) : array
return array

readCookiesFromJar() public method

Reads all the relevant cookies from the cookie jar.
public readCookiesFromJar ( SimpleCookieJar $jar, SimpleUrl $url )
$jar SimpleCookieJar Jar to read
$url SimpleUrl Url to use for scope.