cookies example

static::assertSame(['accept' => ['application/json']]$facade->headers());
    }

    public function testCookies(): void
    {
        $request = new Request();
        $request->cookies->set('foo', 'bar');

        $facade = new RequestFacade($request);

        static::assertSame(['foo' => 'bar']$facade->cookies());
    }

    public function testIp(): void
    {
        $request = new Request();

        $facade = new RequestFacade($request);

        static::assertSame($request->getClientIp()$facade->ip());
    }
}

    public static function create(callable $handler = null): self
    {
        $stack = new self($handler ?: Utils::chooseHandler());
        $stack->push(Middleware::httpErrors(), 'http_errors');
        $stack->push(Middleware::redirect(), 'allow_redirects');
        $stack->push(Middleware::cookies(), 'cookies');
        $stack->push(Middleware::prepareBody(), 'prepare_body');

        return $stack;
    }

    /** * @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler. */
    public function __construct(callable $handler = null)
    {
        $this->handler = $handler;
    }
/** * Actual dispatching of cookies. * Extracted for this to be unit tested. * * @codeCoverageIgnore * * @deprecated Set cookies to Response object instead. */
    protected function doSendCookie(): void
    {
        cookies([$this->cookie], false)->dispatch();
    }

    private function saveHashInSession(): void
    {
        $this->session->set($this->config->tokenName, $this->hash);
    }
}
Home | Imprint | This part of the site doesn't use cookies.