Called when a request is about to be sent

@param Event $event
@throws \OutOfBoundsException When queue is empty
492151
public function onRequestBeforeSend(Event $event)
    {
        if (!$this->queue) {
            throw new \OutOfBoundsException('Mock queue is empty');
        }

        $request = $event['request'];
        $this->received[] = $request;
        // Detach the filter from the client so it's a one-time use
        if ($this->temporary && count($this->queue) == 1 && $request->getClient()) {
            $request->getClient()->getEventDispatcher()->removeSubscriber($this);
        }
        $this->dequeue($request);
    }
1164318
final public function dispatch(Event $event): void
    {
        if (!$event instanceof ReceivedEvent && $this->discriminator->shouldEnqueue($event)) {
            $this->queue->send($event);
        }

        if ($event instanceof ReceivedEvent) {
            $event = $event->getOriginalEvent();
        }

        $this->wrappedEventBus->dispatch($event);
    }
895925
public function onRequestSent(Event $event)
    {
        $request = $event['request'];
        $response = $event['response'];
        $handle = $event['handle'];

        if ($wire = $request->getParams()->get('request_wire')) {
            $request = clone $request;
            $request->setBody($wire);
        }

        if ($wire = $request->getParams()->get('response_wire')) {
            $response = clone $response;
            $response->setBody($wire);
        }

        // Send the log message to the adapter, adding a category and host
        $priority = $response && $response->isError() ? LOG_ERR : LOG_DEBUG;
        $message = $this->formatter->format($request, $response, $handle);
        $this->logAdapter->log($message, $priority, array(
            'request'  => $request,
            'response' => $response,
            'handle'   => $handle
        ));
    }
226318
public function onRequestSent(Event $event)
    {
        $response = $event['response'];
        $request = $event['request'];

        // Only act on redirect requests with Location headers
        if (!$response || $request->getParams()->get(self::DISABLE)) {
            return;
        }

        // Trace the original request based on parameter history
        $original = $this->getOriginalRequest($request);

        // Terminating condition to set the effective repsonse on the original request
        if (!$response->isRedirect() || !$response->hasHeader('Location')) {
            if ($request !== $original) {
                // This is a terminating redirect response, so set it on the original request
                $response->getParams()->set(self::REDIRECT_COUNT, $original->getParams()->get(self::REDIRECT_COUNT));
                $original->setResponse($response);
                $response->setEffectiveUrl($request->getUrl());
            }
            return;
        }

        $this->sendRedirectRequest($original, $request, $response);
    }
1050611
public function onRequestBeforeSend(Event $event)
    {
        if (!strlen($this->config['access_token'])) {
          return;
        }

        switch ($this->config['authorize_location']) {
          case 'query':
            $event['request']->getQuery()->set(
              $this->config['query_param_key'],
              $this->config['access_token']
            );
            break;

          default:
            $authorizationParams = array(
                'access_token'     => $this->config['access_token'],
                'token_type'       => $this->config['token_type'],
            );

            $event['request']->setHeader(
                'Authorization',
                $this->buildAuthorizationHeader($authorizationParams)
            );
            break;
        }
    }
615636
public function onRequestError(Event $event)
	{
		$e = $this->factory->fromResponse($event['request'], $event['response']);
		$event->stopPropagation();
		throw $e;
	}
412138
public function sendEvent(Event $event)
    {
        try {
            $this->eventFactory->addDefaultTagsToEntity($event);
            $this->sendEventThroughSenders($event);
        } catch (\Exception $exception) {
            $this->logException($exception);
        }
    }
826789
public function onPreContentView(PreContentViewEvent $event): void
    {
        $currentRequest = $this->requestStack->getCurrentRequest();
        if (!$currentRequest instanceof Request) {
            return;
        }

        $view = $currentRequest->attributes->get('view');
        if (!$view instanceof ContentValueView) {
            return;
        }

        if ($currentRequest->attributes->get('viewType') !== 'full') {
            return;
        }

        $content = $view->getSiteContent();
        if (!$content->hasField('css_class') || $content->getField('css_class')->isEmpty()) {
            return;
        }

        $fieldValue = $content->getField('css_class')->value;
        if (!$fieldValue instanceof TextLineValue) {
            return;
        }

        $event->getContentView()->addParameters(
            [
                'page_css_class' => trim($fieldValue->text),
            ]
        );
    }
824673
public function listener(Event $event)
    {
        error_log(
            $event->context->get(0)->getRequestTarget() . PHP_EOL,
            3,
            RUNTIME_PATH . '/logs/example.log'
        );
    }
31907
public function handle($event)
    {
        if ($event instanceof RouteMatched) {
            $this->handleLaravelRoute($event);
        }

        if ($event instanceof GzeroRouteMatched) {
            $this->handleRoute($event);
        }
    }
1074832
public function afterHandle($event)
    {
        parent::afterHandle($event);
        
        // reset form_token
        if ($this->request->getMethod() === 'POST') {
            
            if ($this->errorInfo && !$this->errorInfo['errcode'] && $this->options['csrfTokenEnabled'] && $this->options['csrfTokenAutoReset']) {
                $this->resetCsrfToken();
            }
        }
    }
1248274
protected function broadcastEvent($event)
    {
        $connection = ($event instanceof ShouldBroadcastNowInterface) ? 'sync' : null;

        $queue = method_exists($event, 'onQueue') ? $event->onQueue() : null;

        $this->resolveQueue()->connection($connection)->pushOn($queue, 'Nova\Broadcasting\BroadcastEvent', array(
            'event' => serialize(clone $event),
        ));
    }
778234
public function onRequestError(Event $event)
    {
        $request = $event['request'];

        if (!$this->canCache->canCacheRequest($request)) {
            return;
        }

        if ($response = $this->storage->fetch($request)) {
            $response->setHeader(
                'Age',
                time() - strtotime($response->getLastModified() ? : $response->getDate() ?: 'now')
            );

            if ($this->canResponseSatisfyFailedRequest($request, $response)) {
                $request->getParams()->set('cache.hit', 'error');
                $this->addResponseHeaders($request, $response);
                $event['response'] = $response;
                $event->stopPropagation();
            }
        }
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
277623
protected function handleError($event)
    {
        if (error_reporting() & $event->code) {
            $this->getSentryClient()->captureException(
                $this->createErrorException($event->message, $event->code, $event->file, $event->line)
            );
        }
        parent::handleError($event);
    }
1015020
public function onRequestSent(Event $event)
    {
        $request = $event['request'];
        $response = $event['response'];
        $exception = $event['exception'];

        $params = $request->getParams();
        $retries = (int) $params->get(self::RETRY_PARAM);
        $delay = $this->strategy->getBackoffPeriod($retries, $request, $response, $exception);

        if ($delay !== false) {
            // Calculate how long to wait until the request should be retried
            $params->set(self::RETRY_PARAM, ++$retries)
                ->set(self::DELAY_PARAM, microtime(true) + $delay);
            // Send the request again
            $request->setState(RequestInterface::STATE_TRANSFER);
            $this->dispatch(self::RETRY_EVENT, array(
                'request'  => $request,
                'response' => $response,
                'handle'   => $exception ? $exception->getCurlHandle() : null,
                'retries'  => $retries,
                'delay'    => $delay
            ));
        }
    }
106234
public function onRequestPoll(Event $event)
    {
        $request = $event['request'];
        $delay = $request->getParams()->get(self::DELAY_PARAM);

        // If the duration of the delay has passed, retry the request using the pool
        if (null !== $delay && microtime(true) >= $delay) {
            // Remove the request from the pool and then add it back again. This is required for cURL to know that we
            // want to retry sending the easy handle.
            $request->getParams()->remove(self::DELAY_PARAM);
            // Rewind the request body if possible
            if ($request instanceof EntityEnclosingRequestInterface && $request->getBody()) {
                $request->getBody()->seek(0);
            }
            $multi = $event['curl_multi'];
            $multi->remove($request);
            $multi->add($request);
        }
    }