Add headers parsing#22
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.
How about shorter syntax?
| $header = Forwarded::createHeader()->withValues($request->getHeader('Forwarded')); | |
| $header = Forwarded::create($request->getHeader('Forwarded')); |
There was a problem hiding this comment.
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.
| $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.
do you prefer factories over constructors?
There was a problem hiding this comment.
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.
| $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.
What is true for?
public function withTag(string $tag, bool $weak = true): self
There was a problem hiding this comment.
(new ETag('56d-9989200-1132c580')) also possible
(new ETag('W\\56d-9989200-1132c580')) too
There was a problem hiding this comment.
How about this?
$etag = (new ETag('56d-9989200-1132c580'))->weak()->addToResponse($response);There was a problem hiding this comment.
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?
| ->getValues(); | ||
|
|
||
| // создать заголовок My-Sorted-List с перечисляемыми сортируемыми значениями | ||
| $sorted = \Yiisoft\Http\Header\Value\Unnamed\SortedValue::createHeader('My-Sorted-List') |
There was a problem hiding this comment.
These namespaces are very long...
Related yiisoft/yii-web#355, https://trello.com/c/SoSoY4lY/81-add-headers-parsing-to-http-package