kriswallsmith/Buzz

Fix cookie listener

n0n0n0n0 opened this issue · 2 comments

     * Adds Cookie headers to the supplied request.
     *
     * @param RequestInterface $request A request object
     */
    public function addCookieHeaders(RequestInterface $request): RequestInterface
    {
        foreach ($this->getCookies() as $cookie) {
            if ($cookie->matchesRequest($request)) {
                $request = $request->withHeader('Cookie', $cookie->toCookieHeader());
            }
        }

        return $request;
    }

The bug is withHeader will always replace previous cookie so in the end you'll have only ONE cookie, you should use withAddedHeader() method instead to keep all cookies from middleware in request.

You are correct. Thank you. Can you submit a PR?

sure, #342