-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add headers parsing #22
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
Open
roxblnfk
wants to merge
29
commits into
yiisoft:master
Choose a base branch
from
roxblnfk:feature/http-headers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fe0f61a
draft :: first iteration
roxblnfk 1a954d9
draft :: second iteration
roxblnfk cac8cab
draft :: next iteration
roxblnfk bdd0ca7
More tests
roxblnfk 63b61ed
more tests and fixes
roxblnfk d6d9f08
added tests; fixes
roxblnfk a65abeb
Refactoring; Added ParsingException
roxblnfk 3740a76
added some header values
roxblnfk fb60232
Added sorting method for values with quality param
roxblnfk 9f3cb05
added AcceptHeader; refactoring
roxblnfk 1805477
added Russian description draft; some refactoring
roxblnfk 1b0f63d
Documentation is now separated; more tests; more refactoring
roxblnfk 2196232
Header class now immutable; more refactoring; added cache headers and…
roxblnfk fadb06c
Added ETag header
roxblnfk 18f6ee9
added logic for CacheControl and Pragma headers
roxblnfk 5264910
Added CacheControlHeader; docs updated; Date improvements
roxblnfk e0a5dd6
Docs updated; Added methods CONNECT and TRACE; Interfaces moved to `R…
roxblnfk 99090e1
Added logic into Age and Warning headers; @see replaced to @link
roxblnfk 1e0b298
Merge remote-tracking branch 'upstream/master' into feature/http-headers
roxblnfk 784bd80
Refactoring: removed parsing interfaces; parsing params declared in c…
roxblnfk 44717d6
Refactoring: unnamed header values moved to Unnamed namespace; Parser…
roxblnfk 710a8cd
Added `inject` method in the `BaseHeaderValue` class
roxblnfk 8d7c391
Fix doc
roxblnfk a77792e
Merge branch 'master-upstream' into feature/http-headers
roxblnfk d88433e
Merge branch 'master-upstream' into feature/http-headers
roxblnfk 3ae5915
Add psr/http-message again; cleanup
roxblnfk 27609a4
Cleanup
roxblnfk afeaf21
Fix some codestyle
roxblnfk 3ae1418
Apply cs diff
roxblnfk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # HTTP Package | ||
|
|
||
| All HTTP/1.1 messages consist of a start-line followed by a sequence of octets in a format similar to the Internet | ||
| Message Format [RFC5322](https://tools.ietf.org/html/rfc5322): zero or more header fields (collectively referred to as | ||
| the "headers" or the "header section"), an empty line indicating the end of the header section, and an optional message | ||
| body. | ||
|
|
||
| - [HTTP start line](http-start-line.md) (Method constants and status codes) | ||
| - [HTTP headers](http-headers.md) | ||
|
|
||
| Related links to RFC: | ||
|
|
||
| * [RFC7230](https://tools.ietf.org/html/rfc7230) HTTP/1.1: Message Syntax and Routing | ||
| * [RFC7231](https://tools.ietf.org/html/rfc7231) HTTP/1.1: Semantics and Content | ||
| * [RFC7232](https://tools.ietf.org/html/rfc7232) HTTP/1.1: Conditional Requests | ||
| * [RFC7233](https://tools.ietf.org/html/rfc7233) HTTP/1.1: Range Requests | ||
| * [RFC7234](https://tools.ietf.org/html/rfc7234) HTTP/1.1: Caching | ||
| * [RFC7235](https://tools.ietf.org/html/rfc7235) HTTP/1.1: Authentication |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # HTTP start line | ||
|
|
||
| An HTTP message can be either a request from client to server or a response from server to client. Syntactically, the | ||
| two types of message differ in the start-line, which is either a request-line (for requests) or a status-line | ||
| (for responses). | ||
|
|
||
| ## Method constants | ||
|
|
||
| Individual HTTP methods could be referenced as | ||
|
|
||
| ```php | ||
| use Yiisoft\Http\Method; | ||
|
|
||
| Method::GET; | ||
| Method::POST; | ||
| Method::PUT; | ||
| Method::DELETE; | ||
| Method::PATCH; | ||
| Method::HEAD; | ||
| Method::OPTIONS; | ||
| ``` | ||
|
|
||
| To have a list of these, use: | ||
|
|
||
| ```php | ||
| use Yiisoft\Http\Method; | ||
|
|
||
| Method::ALL; | ||
| ``` | ||
|
|
||
| ## HTTP status codes | ||
|
|
||
| Status codes could be referenced by name as: | ||
|
|
||
| ```php | ||
| use Yiisoft\Http\Status; | ||
|
|
||
| Status::NOT_FOUND; | ||
| ``` | ||
|
|
||
| Status text could be obtained as the following: | ||
|
|
||
| ```php | ||
| use Yiisoft\Http\Status; | ||
|
|
||
| Status::TEXTS[Status::NOT_FOUND]; | ||
| ``` | ||
|
|
||
| # ContentDispositionHeader usage | ||
|
|
||
| `ContentDispositionHeader` methods are static so usage is like the following: | ||
|
|
||
| ```php | ||
| $name = \Yiisoft\Http\ContentDispositionHeader::name(); | ||
|
|
||
| $value = \Yiisoft\Http\ContentDispositionHeader::value( | ||
| \Yiisoft\Http\ContentDispositionHeader::INLINE, | ||
| 'avatar.png' | ||
| ); | ||
|
|
||
| $value = \Yiisoft\Http\ContentDispositionHeader::inline('document.pdf'); | ||
|
|
||
| $value = \Yiisoft\Http\ContentDispositionHeader::attachment('document.pdf'); | ||
| ``` | ||
|
|
||
| # PSR-7 and PSR-17 PhpStorm meta | ||
|
|
||
| The package includes PhpStorm meta-files that help IDE to provide values when completing code in cases such as: | ||
|
|
||
| ```php | ||
| use Psr\Http\Message\ResponseFactoryInterface; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Yiisoft\Http\Header; | ||
| use Yiisoft\Http\Status; | ||
|
|
||
| class StaticController | ||
| { | ||
| private ResponseFactoryInterface $responseFactory; | ||
|
|
||
| public function actionIndex(): ResponseInterface | ||
| { | ||
| return $this->responseFactory->createResponse() | ||
| ->withStatus(Status::OK) | ||
| ->withoutHeader(Header::ACCEPT); | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # HTTP Package | ||
|
|
||
| All HTTP/1.1 messages consist of a start-line followed by a sequence of octets in a format similar to the Internet | ||
| Message Format [RFC5322](https://tools.ietf.org/html/rfc5322): zero or more header fields (collectively referred to as | ||
| the "headers" or the "header section"), an empty line indicating the end of the header section, and an optional message | ||
| body. | ||
|
|
||
| - [HTTP start line](http-start-line.md) (Method constants and status codes) | ||
| - [HTTP заголовки](http-headers.md) | ||
|
|
||
| Ссылки на RFC: | ||
|
|
||
| * [RFC7230](https://tools.ietf.org/html/rfc7230) HTTP/1.1: Message Syntax and Routing | ||
| * [RFC7231](https://tools.ietf.org/html/rfc7231) HTTP/1.1: Semantics and Content | ||
| * [RFC7232](https://tools.ietf.org/html/rfc7232) HTTP/1.1: Conditional Requests | ||
| * [RFC7233](https://tools.ietf.org/html/rfc7233) HTTP/1.1: Range Requests | ||
| * [RFC7234](https://tools.ietf.org/html/rfc7234) HTTP/1.1: Caching | ||
| * [RFC7235](https://tools.ietf.org/html/rfc7235) HTTP/1.1: Authentication | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.