Skip to content

Add headers parsing#22

Open
roxblnfk wants to merge 29 commits into
yiisoft:masterfrom
roxblnfk:feature/http-headers
Open

Add headers parsing#22
roxblnfk wants to merge 29 commits into
yiisoft:masterfrom
roxblnfk:feature/http-headers

Conversation

@roxblnfk
Copy link
Copy Markdown
Member

@roxblnfk roxblnfk commented Feb 25, 2021

Q A
New feature? ✔️
Breaks BC?

Related yiisoft/yii-web#355, https://trello.com/c/SoSoY4lY/81-add-headers-parsing-to-http-package

  • Refactor API
  • Refactor tests
    • Separate tests for parser
    • Add more test cases
  • Write docs
  • Decide TODOs
  • Psalm issues
  • Kill mutants

…onstants; create some specific base classes; added Directives group
… and related parameters moved to separate classes
# Conflicts:
#	README.md
#	src/Method.php
@roxblnfk roxblnfk added the status:under development Someone is working on a pull request. label Feb 25, 2021
@roxblnfk roxblnfk marked this pull request as ready for review February 25, 2021 11:47
Comment thread docs/ru/README.md
Comment thread src/Header/AcceptHeader.php
Comment thread docs/ru/http-headers.md
use \Yiisoft\Http\Header\Value\Forwarded;

/** @var \Psr\Http\Message\ServerRequestInterface $request */
$header = Forwarded::createHeader()->withValues($request->getHeader('Forwarded'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about shorter syntax?

Suggested change
$header = Forwarded::createHeader()->withValues($request->getHeader('Forwarded'));
$header = Forwarded::create($request->getHeader('Forwarded'));

Copy link
Copy Markdown
Member Author

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

Comment thread docs/ru/http-headers.md
Comment thread docs/ru/http-headers.md
Вы можете использовать класс `Date` для конвертирования объекта `\DateTimeInterface` в строку формата времени HTTP.

```php
$date = new \Yiisoft\Http\Header\Value\Date(new DateTimeImmutable('2020-01-01 00:00:00 +0000'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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');

Copy link
Copy Markdown
Member Author

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?

Copy link
Copy Markdown
Member

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.

Comment thread docs/ru/http-headers.md
use Yiisoft\Http\Header\Value\Condition\ETag;
/** @var \Psr\Http\Message\ResponseInterface $response */

$etag = (new ETag())->withTag('56d-9989200-1132c580', true)->inject($response);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$etag = (new ETag())->withTag('56d-9989200-1132c580', true)->inject($response);
$etag = (new ETag('56d-9989200-1132c580'))->addToResponse($response);

What is true for?

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member

@samdark samdark Mar 1, 2021

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);

Copy link
Copy Markdown
Member Author

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weak() is alright.

Comment thread docs/ru/http-headers.md
Comment thread docs/ru/http-headers.md
->getValues();

// создать заголовок My-Sorted-List с перечисляемыми сортируемыми значениями
$sorted = \Yiisoft\Http\Header\Value\Unnamed\SortedValue::createHeader('My-Sorted-List')
Copy link
Copy Markdown
Member

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:under development Someone is working on a pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants