-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
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
Add headers parsing #22
base: master
Are you sure you want to change the base?
Conversation
…onstants; create some specific base classes; added Directives group
… and related parameters moved to separate classes
# Conflicts: # README.md
# Conflicts: # README.md # src/Method.php
use \Yiisoft\Http\Header\Value\Forwarded; | ||
|
||
/** @var \Psr\Http\Message\ServerRequestInterface $request */ | ||
$header = Forwarded::createHeader()->withValues($request->getHeader('Forwarded')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about shorter syntax?
$header = Forwarded::createHeader()->withValues($request->getHeader('Forwarded')); | |
$header = Forwarded::create($request->getHeader('Forwarded')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forwarded::createHeader
as nameless will be Value::createValueCollection
, not Value::createValue
Вы можете использовать класс `Date` для конвертирования объекта `\DateTimeInterface` в строку формата времени HTTP. | ||
|
||
```php | ||
$date = new \Yiisoft\Http\Header\Value\Date(new DateTimeImmutable('2020-01-01 00:00:00 +0000')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$date = new \Yiisoft\Http\Header\Value\Date(new DateTimeImmutable('2020-01-01 00:00:00 +0000')); | |
$date = new \Yiisoft\Http\Header\Value\Date::fromDateTime(new DateTimeImmutable('2020-01-01 00:00:00 +0000')); | |
$date = new \Yiisoft\Http\Header\Value\Date::string('2020-01-01'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you prefer factories over constructors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if there are multiple ways to create an object.
use Yiisoft\Http\Header\Value\Condition\ETag; | ||
/** @var \Psr\Http\Message\ResponseInterface $response */ | ||
|
||
$etag = (new ETag())->withTag('56d-9989200-1132c580', true)->inject($response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$etag = (new ETag())->withTag('56d-9989200-1132c580', true)->inject($response); | |
$etag = (new ETag('56d-9989200-1132c580'))->addToResponse($response); |
What is true
for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is true for?
public function withTag(string $tag, bool $weak = true): self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(new ETag('56d-9989200-1132c580'))
also possible
(new ETag('W\\56d-9989200-1132c580'))
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
$etag = (new ETag('56d-9989200-1132c580'))->weak()->addToResponse($response);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
it is possible. Right now you can not set the weak
value saparated from value.
weak()
or withWeak()
?
Shoul i remove the with
prefix in all immutable methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weak()
is alright.
->getValues(); | ||
|
||
// создать заголовок My-Sorted-List с перечисляемыми сортируемыми значениями | ||
$sorted = \Yiisoft\Http\Header\Value\Unnamed\SortedValue::createHeader('My-Sorted-List') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These namespaces are very long...
Related yiisoft/yii-web#355, https://trello.com/c/SoSoY4lY/81-add-headers-parsing-to-http-package