Dispatch on-request event

@param  RequestInterface $request
@return RequestInterface
320176
protected function dispatchOnRequest(RequestInterface $request): RequestInterface
    {
        $requestEvent = new RequestEvent($request);
        $this->dispatcher->dispatch($this->requestEvent, $requestEvent);

        return $requestEvent->getRequest();
    }
1315146
protected function sendErrorEvent(RequestInterface $request, $reason)
    {
        $key = $this->getEventKey($request);
        $event = $this->events[$key];

        unset($this->events[$key]);

        $event->setExecutionStop();
        $event->setReason($reason);
        $this->eventDispatcher->dispatch(GuzzleHttpEvent::EVENT_ERROR_NAME, $event);
    }
1208049
public function handle(RequestInterface $request): ResponseInterface
    {
        if (!array_key_exists($this->index, $this->middlewares)) {
            return $this->response;
        }

        $current = $this->index;

        ++$this->index;

        $response = $this->container->call([$this->middlewares[$current], 'process'], [$request, $this]);

        return $response;
    }
1367228
protected function onFailure(RequestInterface $request)
    {
        return function ($reason) use ($request) {
            if ($this->enabled) {
                $response = null;

                if ($reason instanceof RequestException) {
                    $response = $reason->getResponse();
                }

                $this->log($request, $response);
            }

            return Promise\rejection_for($reason);
        };
    }
1225224
public function dispatch(RequestInterface $request, ResponseInterface $response)
    {
        $this->middleware = array_reverse($this->middleware);

        $resolved = $this->resolve(0);

        return yield $resolved($request, $response);
    }
539610
public function setRequest(RequestInterface $request, array $options = []): self
    {
        $this->requestOrign = $request;
        $this->requestOption = $options;
        return $this;
    }
1322157
protected function onSuccess(RequestInterface $request)
    {
        return function ($response) use ($request) {
            $this->log($request, $response);
            return $response;
        };
    }
663536
public function execute(RequestInterface $request): RequestInterface
    {
        if (is_null($this->sessionToken)) {
            return $request;
        } else {
            return $request->withHeader(
                self::HEADER_CLIENT_AUTHENTICATION,
                [$this->sessionToken->getToken()]
            );
        }
    }
1316993
public function handle(RequestInterface $request)
    {
        $route = $this->dispatch($request);

        $handler = new ResolverHandler($this->container, $route);

        if (count($route->middlewares()) > 0)
        {
            $middlewares = (array) $route->middlewares();

            $dispatcher = new Dispatcher($middlewares, $this->container);

            return $dispatcher->process($request, $handler);
        }

        return $handler->handle($request);
    }
901792
public function dispatch(EventInterface $event)
    {
        if (array_key_exists($event->getName(), $this->listeners)) {
            foreach ($this->listeners[$event->getName()] as $listener) {
                $listener($event);
            }
        }

        return $event;
    }
259623
public function handle(RequestInterface $request): RequestInterface
    {
        return
            $request->withHeader(
                'Authorization',
                sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->user, $this->password)))
            );
    }
1100008
public function onRequest( RequestInterface $request ) {
        $apiKey = $this->getEndpoint()->getApiKey();

        if($apiKey !== null) {
            $request = $request->withHeader( 'Authorization', 'Bearer '.$apiKey);
        }

        return $request;
    }
1299228
public function setRequest(RequestInterface $request)
    {
        $this->setParam('request', $request);
        $this->request = $request;

        return $this;
    }
1162437
public function sendRequest(RequestInterface $request)
    {
        if (isset($this->promises[$request->getRequestId()])) {
            return promise\reject(new ClientException("ID {$request->getRequestId()} already in use"));
        }
        $this->responseBuilders[$request->getRequestId()] = new ResponseParser($request->getRequestId());
        $this->promises[$request->getRequestId()] = new Deferred();
        foreach ($request->toRecords() as $record) {
            $this->connector->write($record->encode());
        }

        return $this->promises[$request->getRequestId()]->promise();
    }
461109
public function execute(RequestInterface $request): RequestInterface
    {
        if ($request->getUri()->getPath() === self::ENDPOINT_INSTALLATION) {
            return $request;
        } else {
            $signature = $this->determineRequestSignature(
                $request->getUri(),
                $request->getMethod(),
                $request->getBody()->getContents(),
                $request->getHeaders()
            );

            return $request->withHeader(self::HEADER_CLIENT_SIGNATURE, $signature);
        }
    }
1271800
public function process(RequestInterface $request, ...$args): bool
    {
        $path = $request->getPath('string');
        $method = $request->getMethod();
        $event = $method.' '.$path;

        return $this
            ->getEventHandler()
            ->trigger($event, $request, ...$args)
            ->getMeta() !== EventHandler::STATUS_INCOMPLETE;
    }
325303
public function decorate(RequestInterface $request)
    {
        return $request->withHeader($this->headerName, $this->requestIdProvider->getRequestId());
    }