Event triggered right before sending a request

@param Event $event
972468
public function onBeforeSend(Event $event)
    {
        /** @var \Guzzle\Http\Message\Request $request */
        $request = $event['request'];

        list($newUrl, $port) = $this->proxify(
            $request->getUrl(),
            $this->bucketKey,
            $this->gatewayHost
        );

        $request->setUrl($newUrl);

        if ($port) {
            $request->setHeader('Runscope-Request-Port', $port);
        }

        if ($this->authToken) {
            $request->setHeader('Runscope-Bucket-Auth', $this->authToken);
        }
    }
177832
public function trigger(Event $event) {
    $request = $event->getTarget();
    
    $cachedRequest = new CachedRequest($request->getURL());
    $cachedRequest->setCachedResponse($event->getData()->response);
    $cachedRequest->setHeaders($event->getData()->headers);
    
    $this->addCachedRequest($cachedRequest);
  }
951499
public function beforeRender(\Cake\Event\Event $event)
    {
        $this->_beforeRender($event);
        $this->Breadcrumb
            ->push('/admin/user/manage')
            ->push(__d('user', 'Virtual Fields'), '#');
    }
519201
public function send(Event $event)
    {
        $message = $this->getEventMessage($event);
        $this->flush($message);
    }
286351
public function onRequestCreate(Event $event)
    {
        $event['request']->setAuth($this->username, $this->password, $this->scheme);
    }
10223
public function beforeRender(Event $event): void
    {
        $this->setJson('isAjax', $this->_controller->request->is('ajax'));
        $this->setJson('isMobile', $this->_controller->request->is('mobile'));
        $this->setBoth('isDialog', $this->_controller->request->is('dialog'));
        $this->setBoth('isJson', $this->_controller->request->is('json'));
        $this->setJson('debug', Configure::read('debug'));

        $ssl = false;
        if (env('HTTPS') || $this->_controller->request->is('ssl') || $this->_controller->request->env('HTTP_X_FORWARDED_PROTO') == 'https') {
            $ssl = true;
        }

        $appData = array(
            'jsonData' => $this->_jsonData,
            'webroot' => 'http' . ($ssl ? 's' : '') . '://' . env('HTTP_HOST') . $this->_controller->request->webroot,
            'url' => $this->_controller->request->url,
            // 'controller' => $this->_controller->name,
            // 'action' => $this->_controller->request->action,
            // 'plugin' => $this->_controller->request->plugin,
            'request' => array(
                'query' => $this->_controller->request->query,
                'pass' => $this->_controller->request->params['pass'],
                'plugin' => $this->_controller->request->plugin,
                'controller' => Inflector::underscore($this->_controller->name),
                'action' => $this->_controller->request->action
            )
        );

        // merge in the additional frontend data
        $appData = Hash::merge($appData, $this->_additionalAppData);
        $this->_controller->set('frontendData', $appData);
        $this->_controller->set('closeDialog', $this->_closeDialog);
    }
472019
public function beforeRender(Event $event)
    {
        if (!array_key_exists('_serialize', $this->viewVars) &&
            in_array($this->response->type(), ['application/json', 'application/xml'])
        ) {
            $this->set('_serialize', true);
        }
    }
928117
public function onRequestRetry(Event $event)
    {
        $this->logger->log($this->formatter->format(
            $event['request'],
            $event['response'],
            $event['handle'],
            array(
                'retries' => $event['retries'],
                'delay'   => $event['delay']
            )
        ));
    }
240035
public function beforeDelete($event)
    {
        $oldId = $this->owner->{$this->savedAttribute};
        if (($oldModel = FileModel::findOne($oldId)) !== null) {
            $event->isValid = $event->isValid && $oldModel->delete();
        }
    }
880388
public function onRequestBeforeSend(Event $event)
    {
        $request = $event['request'];
        $request->addHeader('Via', sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION));

        if (!$this->canCache->canCacheRequest($request)) {
            switch ($request->getMethod()) {
                case 'PURGE':
                    $this->purge($request);
                    $request->setResponse(new Response(200, array(), 'purged'));
                    break;
                case 'PUT':
                case 'POST':
                case 'DELETE':
                case 'PATCH':
                    if ($this->autoPurge) {
                        $this->purge($request);
                    }
            }
            return;
        }

        if ($response = $this->storage->fetch($request)) {
            $params = $request->getParams();
            $params['cache.lookup'] = true;
            $response->setHeader(
                'Age',
                time() - strtotime($response->getDate() ? : $response->getLastModified() ?: 'now')
            );
            // Validate that the response satisfies the request
            if ($this->canResponseSatisfyRequest($request, $response)) {
                if (!isset($params['cache.hit'])) {
                    $params['cache.hit'] = true;
                }
                $request->setResponse($response);
            }
        }
    }
1118595
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        $this->Auth->allow([]);
    }
421088
public function onBefore(BeforeEvent $event)
    {
        $request = $event->getRequest();
        $options = $request->getConfig();

        $videoManagerId = isset($options['videoManagerId']) ? $options['videoManagerId'] : null;
        $token = $this->tokenManager->getToken($videoManagerId);

        if (null !== $token) {
            $request->setHeader('Authorization', sprintf(self::AUTH_BEARER, $token));
        }
    }
1105126
public function onRequestBeforeSend(Event $event)
    {
        $timestamp = $this->getTimestamp($event);
        $request = $event['request'];
        $nonce = $this->generateNonce($request);

        $authorizationParams = array(
            'oauth_callback'         => $this->config['callback'],
            'oauth_consumer_key'     => $this->config['consumer_key'],
            'oauth_nonce'            => $nonce,
            'oauth_signature'        => $this->getSignature($request, $timestamp, $nonce),
            'oauth_signature_method' => $this->config['signature_method'],
            'oauth_timestamp'        => $timestamp,
            'oauth_token'            => $this->config['token'],
            'oauth_verifier'         => $this->config['verifier'],
            'oauth_version'          => $this->config['version'],
        );

        $request->setHeader(
            'Authorization',
            $this->buildAuthorizationHeader($authorizationParams)
        );

        return $authorizationParams;
    }
176630
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();
		$client = $command->getClient();

		if ($command->getName() !== 'createEntity') return;
		if ($command['collection'] !== 'files' && $client->getCollectionName() !== 'files') return;

		$file = new File($command['path']);

		$operation->setResponseClass('GovTribe\LaravelKinvey\Client\KinveyFileResponse');

		$operation->addParam(new Parameter(array(
			'name' => 'path',
			'type' => 'string',
			'default' => $command['path'],
		)));

		$operation->addParam(new Parameter(array(
			'name' => '_public',
			'location' => 'json',
			'type' => 'boolean',
			'default' => isset($command['_public']) ? $command['_public'] : false,
		)));

		$operation->addParam(new Parameter(array(
			'name' => '_filename',
			'location' => 'json',
			'type' => 'string',
			'default' => !isset($command['_filename']) ? $file->getBaseName() : $command['_filename'],
		)));

		$operation->addParam(new Parameter(array(
			'name' => 'size',
			'location' => 'json',
			'type' => 'integer',
			'default' => $file->getSize(),
		)));

		$operation->addParam(new Parameter(array(
			'name' => 'mimeType',
			'location' => 'json',
			'type' => 'string',
			'default' => $file->getMimeType(),
		)));
	}
322408
public function onRequestBeforeSend(Event $event) {
        if ($this->token != null) {
            $event['request']->setHeader('x-cos-security-token', $this->token);
        }
/*
        if(!$this->credentials instanceof NullCredentials) {
            $this->signature->signRequest($event['request'], $this->credentials);
        }
*/
    }
1188908
public function beforeSend()
    {
        $this->client->beforeSend($this);

        $event = new RequestEvent();
        $event->request = $this;
        $this->trigger(self::EVENT_BEFORE_SEND, $event);
    }
467827
public function beforeRequest()
    {
        $this->_ajax = array();

        if (count($this->beforeRequestEvents) > 0) {
            foreach ($this->beforeRequestEvents as $event) {
                $event->onEvent($this);
            }
        }
    }