We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The code:
$request = (new Client())->get('http://test.site'); $request->cookies->add(new Cookie(['name' => 'name1', 'value' => 'value1'])); echo $request->toString();
Produce next output:
GET http://test.site
There is no Cookie header.
But if add to request any headers:
$request = (new Client())->get('http://test.site'); $request->headers->add('Test-Header', 'Test-Value'); $request->cookies->add(new Cookie(['name' => 'name1', 'value' => 'value1'])); echo $request->toString();
Then output is right:
GET http://test.site Test-Header: Test-Value Cookie: name1=value1
This is because Message::toString() check headers existence BEFORE it composing:
if ($this->hasHeaders()) { $headers = $this->composeHeaderLines();
Request::composeHeaderLines() overrides Message:composeHeaderLines and compose cookies header after:
public function composeHeaderLines() { $headers = parent::composeHeaderLines(); if ($this->hasCookies()) { $headers[] = $this->composeCookieHeader(); }
To fix this, we need override Message::hasHeaders in Request also:
public function hasHeaders() { return parent::hasHeaders() || $this-hasCookies(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The code:
Produce next output:
There is no Cookie header.
But if add to request any headers:
Then output is right:
This is because Message::toString() check headers existence BEFORE it composing:
Request::composeHeaderLines() overrides Message:composeHeaderLines and compose cookies header after:
To fix this, we need override Message::hasHeaders in Request also:
The text was updated successfully, but these errors were encountered: