PHP Класс Neos\Flow\Http\Client\Browser

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$automaticRequestHeaders Neos\Flow\Http\Headers
$followRedirects boolean If redirects should be followed
$lastRequest Neos\Flow\Http\Request
$lastResponse Neos\Flow\Http\Response
$maximumRedirections integer The very maximum amount of redirections to follow if there is a "Location" redirect (see also $redirectionStack property)
$redirectionStack array A simple string array that keeps track of occurred "Location" header redirections to avoid infinite loops if the same redirection happens
$requestEngine Neos\Flow\Http\Client\RequestEngineInterface

Открытые методы

Метод Описание
__construct ( ) Construct the Browser instance.
addAutomaticRequestHeader ( string $name, array | string | DateTime $values ) : void Allows to add headers to be sent with every request the browser executes.
getCrawler ( ) : Crawler Returns the DOM crawler which can be used to interact with the web page structure, submit forms, click links or fetch specific parts of the website's contents.
getForm ( string $xpath = '//form' ) : Form Get the form specified by $xpath. If no $xpath given, return the first form on the page.
getLastRequest ( ) : Request Returns the last request executed.
getLastResponse ( ) : Response Returns the response received after the last request.
getRequestEngine ( ) : Neos\Flow\Http\Client\RequestEngineInterface Returns the request engine used by this Browser.
removeAutomaticRequestHeader ( string $name ) : void Allows to remove headers that were added with addAutomaticRequestHeader.
request ( string | Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [], string $content = null ) : Response Requests the given URI with the method and other parameters as specified.
sendRequest ( Request $request ) : Response Sends a prepared request and returns the respective response.
setFollowRedirects ( boolean $flag ) : void Sets a flag if redirects should be followed or not.
setRequestEngine ( Neos\Flow\Http\Client\RequestEngineInterface $requestEngine ) : void Inject the request engine
submit ( Form $form ) : Response Submit a form

Описание методов

__construct() публичный Метод

Construct the Browser instance.
public __construct ( )

addAutomaticRequestHeader() публичный Метод

Allows to add headers to be sent with every request the browser executes.
См. также: Message::setHeader()
public addAutomaticRequestHeader ( string $name, array | string | DateTime $values ) : void
$name string Name of the header, for example "Location", "Content-Description" etc.
$values array | string | DateTime An array of values or a single value for the specified header field
Результат void

getCrawler() публичный Метод

The returned DOM crawler is bound to the response of the last executed request.
public getCrawler ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler

getForm() публичный Метод

Get the form specified by $xpath. If no $xpath given, return the first form on the page.
public getForm ( string $xpath = '//form' ) : Form
$xpath string
Результат Symfony\Component\DomCrawler\Form

getLastRequest() публичный Метод

Returns the last request executed.
public getLastRequest ( ) : Request
Результат Neos\Flow\Http\Request The HTTP request or NULL if there wasn't a request yet

getLastResponse() публичный Метод

Returns the response received after the last request.
public getLastResponse ( ) : Response
Результат Neos\Flow\Http\Response The HTTP response or NULL if there wasn't a response yet

getRequestEngine() публичный Метод

Returns the request engine used by this Browser.
public getRequestEngine ( ) : Neos\Flow\Http\Client\RequestEngineInterface
Результат Neos\Flow\Http\Client\RequestEngineInterface

removeAutomaticRequestHeader() публичный Метод

Allows to remove headers that were added with addAutomaticRequestHeader.
public removeAutomaticRequestHeader ( string $name ) : void
$name string Name of the header, for example "Location", "Content-Description" etc.
Результат void

request() публичный Метод

If a Location header was given and the status code is of response type 3xx (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, 14.30 Location)
public request ( string | Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [], string $content = null ) : Response
$uri string | Neos\Flow\Http\Uri
$method string Request method, for example "GET"
$arguments array Arguments to send in the request body
$files array
$server array
$content string
Результат Neos\Flow\Http\Response The HTTP response

sendRequest() публичный Метод

Sends a prepared request and returns the respective response.
public sendRequest ( Request $request ) : Response
$request Neos\Flow\Http\Request
Результат Neos\Flow\Http\Response

setFollowRedirects() публичный Метод

Sets a flag if redirects should be followed or not.
public setFollowRedirects ( boolean $flag ) : void
$flag boolean
Результат void

setRequestEngine() публичный Метод

Inject the request engine
public setRequestEngine ( Neos\Flow\Http\Client\RequestEngineInterface $requestEngine ) : void
$requestEngine Neos\Flow\Http\Client\RequestEngineInterface
Результат void

submit() публичный Метод

Submit a form
public submit ( Form $form ) : Response
$form Symfony\Component\DomCrawler\Form
Результат Neos\Flow\Http\Response

Описание свойств

$automaticRequestHeaders защищенное свойство

protected Headers,Neos\Flow\Http $automaticRequestHeaders
Результат Neos\Flow\Http\Headers

$followRedirects защищенное свойство

If redirects should be followed
protected bool $followRedirects
Результат boolean

$lastRequest защищенное свойство

protected Request,Neos\Flow\Http $lastRequest
Результат Neos\Flow\Http\Request

$lastResponse защищенное свойство

protected Response,Neos\Flow\Http $lastResponse
Результат Neos\Flow\Http\Response

$maximumRedirections защищенное свойство

The very maximum amount of redirections to follow if there is a "Location" redirect (see also $redirectionStack property)
protected int $maximumRedirections
Результат integer

$redirectionStack защищенное свойство

A simple string array that keeps track of occurred "Location" header redirections to avoid infinite loops if the same redirection happens
protected array $redirectionStack
Результат array

$requestEngine защищенное свойство

protected RequestEngineInterface,Neos\Flow\Http\Client $requestEngine
Результат Neos\Flow\Http\Client\RequestEngineInterface