Skip to content

Add the append method for the Headers API - #12467

Merged
bors-servo merged 4 commits into
servo:masterfrom
jeenalee:jeena-headersAPI
Jul 20, 2016
Merged

bors-servo merged 4 commits into
servo:masterfrom
jeenalee:jeena-headersAPI

Conversation

@jeenalee

@jeenalee jeenalee commented Jul 15, 2016 •

Copy link
Copy Markdown
Contributor

This commit adds the append method for the Headers API. @malisas and I are both contributors.

There are a few TODOs related:

  • The script needs to parse the header value for certain header names to decide the header group it belongs
  • There are possible spec bugs that could change what a valid header value looks like (related: issue page)

There are WPT tests already written for the Headers API, but they will fail as the Headers API is not fully implemented.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • 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.

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/webidls/Headers.webidl, components/script/dom/mod.rs, components/script/dom/headers.rs, components/script/dom/bindings/str.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 15, 2016
@fitzgen

fitzgen commented Jul 15, 2016

Copy link
Copy Markdown
Contributor

r? @jdm

@jeenalee

Copy link
Copy Markdown
Contributor Author

r? @jdm
cc: @malisas

@highfive highfive assigned jdm and unassigned Manishearth Jul 15, 2016
@jdm jdm removed the S-awaiting-review There is new code that needs to be reviewed. label Jul 15, 2016
@jdm

jdm commented Jul 15, 2016

Copy link
Copy Markdown
Member

Good start! I've left some comments on ways I think we can make the code more readable.
-S-awaiting-review +S-needs-code-changes


Reviewed 6 of 6 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 30 unresolved discussions, some commit checks failed.


components/script/dom/headers.rs, line 39 [r2] (raw file):

impl Headers {
    pub fn new() -> Headers {

This should be called new_inherited, and a new method should return Root<Headers>.


components/script/dom/headers.rs, line 61 [r2] (raw file):

        //    and name/value is not a CORS-safelisted request-header, return.
        // 6) Otherwise, if guard is "response" and
        //    name is a forbidden response-header name, return.

Rather than writing out comments that duplicate specification text, we should use // Steps 3-6 and let the reader look up the spec if necessary.


components/script/dom/headers.rs, line 66 [r2] (raw file):

            Ok(ns) => name_string = ns,
            Err(_) => return Err(Error::Type(String::from("Non-UTF8 header name found"))),
        }
let name_string = match String::from_utf8(name.into()) {
    Ok(ns) => ns,
    _ => return Err(Error::Type("Non-UTF8 header name found".into()));
};

components/script/dom/headers.rs, line 67 [r2] (raw file):

            Err(_) => return Err(Error::Type(String::from("Non-UTF8 header name found"))),
        }
        let header_group = try!(find_header_group(&name_string));

I think this header group abstraction makes it harder to reason about what this code is actually checking. I'd prefer to have each step written out like in the spec.


components/script/dom/headers.rs, line 86 [r2] (raw file):

// "DPR", "Downlink", "Save-Data", "Viewport-Width", "Width":
// once parsed, the value should not be failure.
fn is_cors_safelisted_request(name: &str) -> bool {

is_cors_safelisted_request_header and link to https://fetch.spec.whatwg.org/#cors-safelisted-request-header .


components/script/dom/headers.rs, line 95 [r2] (raw file):

}

fn is_cors_non_wildcard_request(name: &str) -> bool {

This isn't used by append.


components/script/dom/headers.rs, line 102 [r2] (raw file):

}

// TODO

What's left to do?


components/script/dom/headers.rs, line 108 [r2] (raw file):

// Content-Type, Expires, Last-Modified, Pragma
// Any value in list that is not a forbidden response-header name.
fn is_cors_safelisted_response(name: &str) -> bool {

What does this correspond to in the specification? Append doesn't appear to check for these.


components/script/dom/headers.rs, line 120 [r2] (raw file):

}

fn is_forbidden_response(name: &str) -> bool {

is_forbidden_response_header and add a link to https://fetch.spec.whatwg.org/#forbidden-response-header-name


components/script/dom/headers.rs, line 128 [r2] (raw file):

}

fn is_forbidden(name: &str) -> bool {

is_forbidden_header_name and add a link to https://fetch.spec.whatwg.org/#forbidden-header-name


components/script/dom/headers.rs, line 129 [r2] (raw file):

fn is_forbidden(name: &str) -> bool {
    if name.starts_with("proxy-") ||

If we could merge this with https://dxr.mozilla.org/servo/rev/4cc4bc3c38eff22f9472215261d6926315b42f8d/components/script/dom/xmlhttprequest.rs#416 that would be great. The code there is shorter; I think it would be good to replace this implementation with that one, and have that one call into this one.


components/script/dom/headers.rs, line 198 [r2] (raw file):

// [3] https://tools.ietf.org/html/rfc7230#section-3.2.6
// [4] https://www.rfc-editor.org/errata_search.php?rfc=7230
fn validate_name_and_value(name: &ByteString, value: &ByteString) -> Result<(), Error> {

Let's make this method return Result<(String, Vec<u8>), Error> so the caller only needs to deal with valid values after this point. We can accept ByteString by value instead of as a reference to accomplish this.


components/script/dom/headers.rs, line 202 [r2] (raw file):

        Ok(())
    } else {
        Err(Error::Type(String::from("Name and/or Value are not valid")))

We can have a more specific error message if we do:

if !is_field_name(name) {
    return Err(...);
}
if !is_field_content(value) {
    return Err(...);
}
Ok(())

components/script/dom/headers.rs, line 220 [r2] (raw file):

// Removes trailing and leading HTTP whitespace bytes.
pub fn normalize_value(value: ByteString) -> ByteString {

Add a comment linking to https://fetch.spec.whatwg.org/#concept-header-value-normalize


components/script/dom/headers.rs, line 222 [r2] (raw file):

pub fn normalize_value(value: ByteString) -> ByteString {
    let opt_first_index = index_of_first_non_whitespace(&value);
    match opt_first_index {

What about this instead?

match (index_of_first_non_whitespace(&value), index_of_last_non_whitespace(&value)) {
    (Some(begin), Some(end)) => ByteString::new(value[begin..end].to_owned()),
    _ => ByteString::new(),
}

components/script/dom/headers.rs, line 255 [r2] (raw file):

        byte == 0x0A ||      // new line
        byte == 0x0D ||      // return character
        byte == 0x20;        // space

This can be written as:

fn is_HTTP_whitespace(byte: u8) -> bool {
    byte == b'\t' || byte == b'\n' || byte == b'\r' || b == ' '
}

components/script/dom/headers.rs, line 263 [r2] (raw file):

            continue;
        }
        return Some(index)

Let's write this as:

if !is_HTTP_whitespace(byte) {
    return Some(index);
}

components/script/dom/headers.rs, line 273 [r2] (raw file):

            continue;
        }
        return Some(index)

Same previous comment.


components/script/dom/headers.rs, line 284 [r2] (raw file):

fn is_field_content(value: &ByteString) -> bool {
    // http://tools.ietf.org/html/rfc2616#section-2.2

https://tools.ietf.org/html/rfc7230#section-3.2


components/script/dom/headers.rs, line 310 [r2] (raw file):

fn is_space(x: u8) -> bool {
    return x == 0x20;

This can be x == b' ' without the return.


components/script/dom/headers.rs, line 314 [r2] (raw file):

fn is_htab(x: u8) -> bool {
    return x == 0x09;

This can be x == b'\t'.


components/script/dom/headers.rs, line 322 [r2] (raw file):

fn is_vchar(x: u8) -> bool {
    // http://tools.ietf.org/html/rfc2616#section-2.2

https://tools.ietf.org/html/rfc7230#section-3.2


components/script/dom/headers.rs, line 325 [r2] (raw file):

    // field-vchar = VCHAR / obs-text
    match x {
        0...31 | 127 => false, // CTLs

Let's use 0x00...0x1F | 0x7F per https://tools.ietf.org/html/rfc5234#appendix-B.1, but I'm not clear on where CTLs come into the field-vchar definition?


components/script/dom/headers.rs, line 326 [r2] (raw file):

    match x {
        0...31 | 127 => false, // CTLs
        x if x > 127 => false, // non-CHARs

Could we phrase the checks in this function more like 0x21...0x7E in https://tools.ietf.org/html/rfc5234#appendix-B.1


components/script/dom/headers.rs, line 327 [r2] (raw file):

        0...31 | 127 => false, // CTLs
        x if x > 127 => false, // non-CHARs
        _ => true,

Can we reuse is_obs_text here?


components/script/dom/webidls/Headers.webidl, line 5 [r2] (raw file):

 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// https://fetch.spec.whatwg.org/#header

https://fetch.spec.whatwg.org/#headers-class


tests/unit/script/headers.rs, line 14 [r2] (raw file):

    let actual_normalized_empty_bytestring = headers::normalize(empty_bytestring);
    let expected_normalized_empty_bytestring = ByteString::new(vec![]);
    assert_eq!(actual_normalized_empty_bytestring, expected_normalized_empty_bytestring);

It will be easier to read if these are called actual and expected instead.


tests/unit/script/headers.rs, line 20 [r2] (raw file):

fn test_normalize_all_whitespace_bytestring() {
    // All whitespace test. A horizontal tab, a line feed, a carriage return , and a space
    let all_whitespace_bytestring = ByteString::new(vec![0x09, 0x0A, '\n' as u8, 0x20]);

[b'\t', b'\n', b'\r', b' ']


tests/unit/script/headers.rs, line 23 [r2] (raw file):

    let actual_normalized_whitespace_bytestring = headers::normalize(all_whitespace_bytestring);
    let expected_normalized_whitespace_bytestring = ByteString::new(vec![]);
    assert_eq!(actual_normalized_whitespace_bytestring, expected_normalized_whitespace_bytestring);

Same naming comment for all the tests.


tests/unit/script/headers.rs, line 29 [r2] (raw file):

fn test_normalize_non_empty_no_whitespace_bytestring() {
    // Non-empty, no whitespace ByteString test
    let no_whitespace_bytestring = ByteString::new(vec!['S' as u8, '!' as u8]);

We can use b prefixes to avoid the casts.


Comments from Reviewable

@jdm jdm added the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Jul 15, 2016
@nox

nox commented Jul 16, 2016

Copy link
Copy Markdown
Contributor

AFAIK the spec links should be outside the functions, not inside.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Jul 18, 2016
jeenalee added a commit to jeenalee/servo that referenced this pull request Jul 18, 2016
servo#12467

- Add appropriate spec links
- Remove unnecessary code that is not used by append method
- Simplify code to read more easily
@malisas

malisas commented Jul 19, 2016

Copy link
Copy Markdown
Contributor

@jdm
@jeenalee and I went through your comments and made some changes. The tests also pass now after rebasing. Please let us know if we should change anything else before merging -- thanks! :)

@jdm

jdm commented Jul 19, 2016

Copy link
Copy Markdown
Member

Thanks for addressing those comments! There are still some unaddressed ones in the unit tests, and I've left some new ones.
-S-awaiting-review +S-needs-code-changes


Reviewed 1 of 1 files at r4, 3 of 3 files at r5.
Review status: all files reviewed at latest revision, 9 unresolved discussions.


components/script/dom/headers.rs, line 62 [r5] (raw file):

        // Step 2
        let (valid_name, valid_value) = try!(validate_name_and_value(name, value));
        let header_group = try!(find_header_group(&valid_name));

I still find the following code more readable than the header group abstraction:

// Step 3
if self.guard == Guard::Immutable {
    return ...;
}

// Step 4
if self.guard == Guard::Request && is_forbidden_header_name(valid_name) {
    return ...;
}

components/script/dom/headers.rs, line 123 [r5] (raw file):

    let disallowed_header_prefixes = ["sec-", "proxy-"];

    if disallowed_headers.iter().any(|header| *header == name) ||

Instead of if ... { return true } else { return false }, we can write ... which is equivalent.


components/script/dom/headers.rs, line 176 [r5] (raw file):

    match String::from_utf8(name.into()) {
        Ok(ns) => Ok((ns, value.into())),
        _ => return Err(Error::Type("Non-UTF8 header name found".to_string())),

No need for return here.


components/script/dom/headers.rs, line 205 [r5] (raw file):

    for (index, &byte) in value.iter().enumerate().rev() {
        if !is_HTTP_whitespace(byte) {
            return Some(index);

We should return Some(value.length() - index - 1) instead, or it will be easy to use the value incorrectly like we did earlier.


Comments from Reviewable

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jul 19, 2016
@jeenalee

Copy link
Copy Markdown
Contributor Author

components/script/dom/headers.rs, line 205 [r5] (raw file):

Previously, jdm (Josh Matthews) wrote…

We should return Some(value.length() - index - 1) instead, or it will be easy to use the value incorrectly like we did earlier.

I think it will have to return what you suggested if it were `value.iter().rev().enumerate()`. But because it is written as `enumerate()` then `rev()`, I think it returns the index in the form we want. What do you think?

Comments from Reviewable


fn index_of_last_non_whitespace(value: &ByteString) -> Option<usize> {
for (index, &byte) in value.iter().enumerate().rev() {
if !is_HTTP_whitespace(byte) {

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.

We can use even more iterator magic here!

value.iter().enumerate().rev().find(|_,v| !is_whitespace(v)).map(|i| i.0|)

something like that.

But it's good as is too, some folks prefer to avoid overusing iterator adapters.

@jdm

jdm commented Jul 19, 2016

Copy link
Copy Markdown
Member

Review status: all files reviewed at latest revision, 10 unresolved discussions.


components/script/dom/headers.rs, line 205 [r5] (raw file):

Previously, jeenalee (Jeena Lee) wrote…

I think it will have to return what you suggested if it were value.iter().rev().enumerate(). But because it is written as enumerate() then rev(), I think it returns the index in the form we want. What do you think?

Ooh, you're right. That's subtle!

Comments from Reviewable

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Jul 19, 2016
@jdm

jdm commented Jul 19, 2016

Copy link
Copy Markdown
Member

Almost there! Please go ahead and squash all the changes together into a single commit, as well. I don't think we gain much from having the independent commits when they're all part of implementing a single feature.
-S-awaiting-review +S-needs-code-changes +S-needs-squash


Reviewed 3 of 3 files at r6.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


components/script/dom/headers.rs, line 129 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

If we could merge this with https://dxr.mozilla.org/servo/rev/4cc4bc3c38eff22f9472215261d6926315b42f8d/components/script/dom/xmlhttprequest.rs#416 that would be great. The code there is shorter; I think it would be good to replace this implementation with that one, and have that one call into this one.

What about calling this from xmlhttprequest.rs?

components/script/dom/headers.rs, line 60 [r6] (raw file):

        // Step 4
        if self.guard == Guard::Request && is_forbidden_header_name(&valid_name) {
            return Ok(());;

nit: extra ;


Comments from Reviewable

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jul 19, 2016
This commit will add the append method and associated helper functions, and introduce any necessary changes for it.
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 60549c4 with merge 0bcf291...

bors-servo pushed a commit that referenced this pull request Jul 20, 2016
Add the append method for the Headers API

<!-- Please describe your changes on the following line: -->
This commit adds the append method for the Headers API. @malisas and I are both contributors.

There are a few TODOs related:
- The script needs to parse the header value for certain header names to decide the header group it belongs
- There are possible spec bugs that could change what a valid header value looks like (related: [issue page](whatwg/fetch#332))

There are WPT tests already written for the Headers API, but they will fail as the Headers API is not fully implemented.

---
<!-- 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/12467)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 20, 2016
@jdm

jdm commented Jul 20, 2016

Copy link
Copy Markdown
Member
Tests with unexpected results:
  ▶ Unexpected subtest result in /_mozilla/mozilla/interfaces.html:
  │ FAIL [expected PASS] Interfaces exposed on the window
  │   → assert_true: If this is failing: DANGER, are you sure you want to expose the new interface Headers to all webpages as a property on the global? Do not make a change to this file without review from jdm or Ms2ger for that specific change! expected true got false
  │ 
  │ test_interfaces/<@http://web-platform.test:8000/_mozilla/mozilla/interfaces.js:70:7
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1402:20
  │ test@http://web-platform.test:8000/resources/testharness.js:500:9
  │ test_interfaces@http://web-platform.test:8000/_mozilla/mozilla/interfaces.js:1:3
  └ @http://web-platform.test:8000/_mozilla/mozilla/interfaces.html:6:1

We'll need to add the Headers interface name to the list in tests/wpt/mozilla/tests/mozilla/interfaces.js.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jul 20, 2016
"FocusEvent",
"FormData",
"HashChangeEvent",
"Headers",

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.

This won't work yet, since the Exposed=(Window,Worker) annotation is commented out.

@jdm

jdm commented Jul 20, 2016

Copy link
Copy Markdown
Member

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 094995b has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jul 20, 2016
Expose the Headers interface to the Window scope and to Workers
Move Append function inside HeadersMethods trait
@malisas
malisas force-pushed the jeena-headersAPI branch from 094995b to 272d12d Compare July 20, 2016 18:44
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 20, 2016
@jdm

jdm commented Jul 20, 2016

Copy link
Copy Markdown
Member

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 272d12d has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jul 20, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 272d12d with merge 03fa7f0...

bors-servo pushed a commit that referenced this pull request Jul 20, 2016
Add the append method for the Headers API

<!-- Please describe your changes on the following line: -->
This commit adds the append method for the Headers API. @malisas and I are both contributors.

There are a few TODOs related:
- The script needs to parse the header value for certain header names to decide the header group it belongs
- There are possible spec bugs that could change what a valid header value looks like (related: [issue page](whatwg/fetch#332))

There are WPT tests already written for the Headers API, but they will fail as the Headers API is not fully implemented.

---
<!-- 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/12467)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev

@bors-servo
bors-servo merged commit 272d12d into servo:master Jul 20, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 20, 2016
@malisas malisas mentioned this pull request Jul 28, 2016
3 of 5 tasks
bors-servo pushed a commit that referenced this pull request Jul 28, 2016
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 -->
bors-servo pushed a commit that referenced this pull request Jul 30, 2016
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants