Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHeaders API constructor and methods #12634
Conversation
highfive
commented
Jul 28, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jul 28, 2016
|
r? @jdm |
|
cc myself |
|
Great work! I've also submitted #12636 which will allow us to verify at least some of these changes against automated tests. Reviewed 2 of 2 files at r1. components/script/dom/headers.rs, line 46 [r1] (raw file):
This can be components/script/dom/headers.rs, line 47 [r1] (raw file):
Let's call this components/script/dom/headers.rs, line 52 [r1] (raw file):
Traditional Servo code style is to name this components/script/dom/headers.rs, line 53 [r1] (raw file):
components/script/dom/headers.rs, line 70 [r1] (raw file):
components/script/dom/headers.rs, line 122 [r1] (raw file):
This change isn't part of the fetch specification, so this isn't compatible with the Headers implementation in other browsers. We should remove the special case here and file an issue against the Fetch specification. components/script/dom/headers.rs, line 132 [r1] (raw file):
This can return components/script/dom/headers.rs, line 157 [r1] (raw file):
This can use Fallible. components/script/dom/headers.rs, line 165 [r1] (raw file):
We should remove this note when we remove the spec-incompatible behaviour. components/script/dom/headers.rs, line 167 [r1] (raw file):
Ok(self.header_list.borrow().get_raw(&valid_name).map(|v| {
ByteString::new(v[0].clone())
}))components/script/dom/headers.rs, line 174 [r1] (raw file):
Fallible. components/script/dom/headers.rs, line 183 [r1] (raw file):
Fallible. Comments from Reviewable |
Enable Headers API tests. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes This will be useful for #12634. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12636) <!-- Reviewable:end -->
|
@bors-servo: try |
Headers API constructor and methods <!-- Please describe your changes on the following line: --> This PR fills out the constructor and the delete, get, has, and set methods for the Headers API. Addresses issue #11897 . The PR also rewrites the append method to support `hyper::header::Headers`'s HashMap `insert` method, which overwrites entries instead of appending. As a result of this, for a given header name there is at most one value in the inner "header list"/HashMap. Multiple values for the same name are comma-delimited. There are still a few TODOs: - Support `OpenEndedDictionary<ByteString>` as a possible `HeadersInit` value. [OpenEndedDictionary<T> is a future IDL construct.](https://fetch.spec.whatwg.org/#headers-class) - Support `iterable<ByteString, ByteString>`. Related issue: #12628 - Values are comma-delimited, except for values with the name `set-cookie`, which are newline-delimited. This is because values for `set-cookie` are [allowed to contain](https://tools.ietf.org/html/rfc7230#section-3.2.2) inner commas. This violates the [spec](https://fetch.spec.whatwg.org/#concept-header-value-combined). - The TODOs from PR #12467 regarding value parsing also still need to be resolved. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because tests for the Headers API already exists, but this commit does not implement the interface fully. The tests will fail. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12634) <!-- Reviewable:end -->
|
|
highfive
commented
Jul 28, 2016
|
|
Thanks @jdm for the feedback! |
|
(and here is the filed issue about the |
|
The only remaining change is to update the expected test results and squash the commits together. Reviewed 1 of 1 files at r2. Comments from Reviewable |
- Reworked the append method to support the inner `hyper::header::Headers`'s HashMap `insert` method, which overwrites entries instead of appending. - Filled out constructor as well as delete, get, has, and set methods. - Updated relevant test expectations
|
@bors-servo: r+ |
|
|
Headers API constructor and methods <!-- Please describe your changes on the following line: --> This PR fills out the constructor and the delete, get, has, and set methods for the Headers API. Addresses issue #11897 . The PR also rewrites the append method to support `hyper::header::Headers`'s HashMap `insert` method, which overwrites entries instead of appending. As a result of this, for a given header name there is at most one value in the inner "header list"/HashMap. Multiple values for the same name are comma-delimited. There are still a few TODOs: - Support `OpenEndedDictionary<ByteString>` as a possible `HeadersInit` value. [OpenEndedDictionary<T> is a future IDL construct.](https://fetch.spec.whatwg.org/#headers-class) - Support `iterable<ByteString, ByteString>`. Related issue: #12628 - Values are comma-delimited, except for values with the name `set-cookie`, which are newline-delimited. This is because values for `set-cookie` are [allowed to contain](https://tools.ietf.org/html/rfc7230#section-3.2.2) inner commas. This violates the [spec](https://fetch.spec.whatwg.org/#concept-header-value-combined). - The TODOs from PR #12467 regarding value parsing also still need to be resolved. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because tests for the Headers API already exists, but this commit does not implement the interface fully. The tests will fail. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12634) <!-- Reviewable:end -->
|
|
malisas commentedJul 28, 2016
•
edited by larsbergstrom
This PR fills out the constructor and the delete, get, has, and set methods for the Headers API. Addresses issue #11897 .
The PR also rewrites the append method to support
hyper::header::Headers's HashMapinsertmethod, which overwrites entries instead of appending.As a result of this, for a given header name there is at most one value in the inner "header list"/HashMap. Multiple values for the same name are comma-delimited.
There are still a few TODOs:
OpenEndedDictionary<ByteString>as a possibleHeadersInitvalue. OpenEndedDictionary is a future IDL construct.iterable<ByteString, ByteString>. Related issue: #12628set-cookie, which are newline-delimited. This is because values forset-cookieare allowed to contain inner commas. This violates the spec../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is