Documentation

OnHttpClientBuildRequest

Event is called after creating a query object. It allows to adjust client options and change query object (please, be advise that query object is unmodifiable and all modifications are made using the methods with...). Query object is returned via the event type \Bitrix\Main\Web\Http\RequestEventResult.

Example

\Bitrix\Main\EventManager::getInstance()->addEventHandler('main', 'OnHttpClientBuildRequest', 'MyOnHttpClientBuildRequest');
function MyOnHttpClientBuildRequest(\Bitrix\Main\Web\Http\RequestEvent $event)
{
	$client = $event->getClient();
	$client->setProxy('');
	
	$request = $event->getRequest();
	$request = $request->withHeader('MyHeader', 'MyValue');
	
	$result = new \Bitrix\Main\Web\Http\RequestEventResult($request);
	
	$event->addResult($result);
}


© «Bitrix24», 2001-2024