Skip to content
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

Parsing Content-Type #10525

Merged
merged 12 commits into from
Nov 27, 2018
Merged

Parsing Content-Type #10525

merged 12 commits into from
Nov 27, 2018

Conversation

annevk
Copy link
Member

@annevk annevk commented Apr 18, 2018

See whatwg/mimesniff#30 (comment) and whatwg/mimesniff#30 (comment) for the processing model this is meant to test.

Very much WIP.
annevk added a commit to whatwg/fetch that referenced this pull request Nov 9, 2018
Also known as "extract a MIME type" down right.

Tests: web-platform-tests/wpt#10525.

Helps with #814.

Fixes #529. Closes whatwg/mimesniff#30.
annevk added a commit to whatwg/fetch that referenced this pull request Nov 12, 2018
Also known as "extract a MIME type" down right.

Tests: web-platform-tests/wpt#10525.

Helps with #814.

Fixes #529. Closes whatwg/mimesniff#30.
@annevk
Copy link
Member Author

annevk commented Nov 20, 2018

@MattMenke2 could you review these too?

@MattMenke2
Copy link
Member

Happy to review the test cases, but I'm not at all familiar with the python+js environment used by the wpt tests, so at least that aspect should probably be reviewed by someone familiar with the test environment.

fetch/content-type/resources/content-types.json Outdated Show resolved Hide resolved
"encoding": null
},
{
"input": ["text / javascript"],
Copy link
Member

Choose a reason for hiding this comment

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

Suggest splitting this in two, one with the space in each location.

Also, should the cases be checked (instead or additionally) in wpt/mimesniff/mime-types/resources/mime-types.json?

fetch/content-type/resources/script-content-types.json Outdated Show resolved Hide resolved
document.head.appendChild(script);
if (testData.executes) {
script.onload = t.step_func_done(() => {
assert_equals(self.isThereABetterWay, testData.encoding === "windows-1252" ? "€" : "€");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for checking the encoding here? Also, I have no idea what all the isThereABetterWay stuff is doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's basically making sure the script got decoded correctly. isThereABetterWay is a global variable that the script sets with the decoded string value. It's called that way because I was hoping someone would come up with a better mechanism than a global variable. I'll rename it to something more appropriate.

@annevk
Copy link
Member Author

annevk commented Nov 22, 2018

Thanks a lot, these are great. I'm not doing boundary for now as that basically requires testing (and defining...) that format, which I want to do at some point, but I'm not gonna block on.

I fixed your other points (or left comments), and added documentation to avoid renaming input (and since documentation seems good anyway).

@annevk
Copy link
Member Author

annevk commented Nov 22, 2018

@domenic note that I added some new generic MIME type tests here as well per feedback, you want to run those against your implementation.


An array of tests. Each test has these fields:

* `input`: an array of values for the `Content-Type` header. A harness needs to run the test twice if there are multiple values. One time with the values concatenated with `,` followed by a space and one time with multiple `Content-Type` declarations, each on their own line with one of the values, in order.
Copy link
Member

@MattMenke2 MattMenke2 Nov 26, 2018

Choose a reason for hiding this comment

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

I think think it's better to rename input so the tests are more self-contained. Not going to block on that, though.

@domenic
Copy link
Member

domenic commented Nov 26, 2018

Updates to mimesniff/mime-types/resources/mime-types.json LGTM. One day maybe we'll have a jsdom implementation of fetch that can fully test the other JSON files.

@annevk
Copy link
Member Author

annevk commented Nov 27, 2018

Fair enough, I renamed input to contentType.

@annevk annevk merged commit 62317fb into master Nov 27, 2018
@annevk annevk deleted the annevk/content-type-parsing branch November 27, 2018 09:45
annevk added a commit to whatwg/fetch that referenced this pull request Nov 27, 2018
Also known as "extract a MIME type" done right.

Tests: web-platform-tests/wpt#10525.

Helps with #814.

Fixes #529. Closes whatwg/mimesniff#30.
domenic added a commit to jsdom/whatwg-mimetype that referenced this pull request Nov 28, 2018
Includes web-platform-tests/wpt#10525, which has a few new MIME type parsing tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants