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

Test if we correctly strip request-body-headers for redirects #20596

Merged
merged 5 commits into from Dec 11, 2019

Conversation

JuniorHsu
Copy link
Contributor

Issue: whatwg/fetch#609
Spec change: whatwg/fetch#977

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This generally looks okay, but I think we should have coverage for all headers to be removed (and maybe also check that other headers are not removed) and also some arbitrary methods, such as TESTING or some such.


promise_test(function(test) {
return fetch(url + urlParameters, requestInit).then(function(resp) {
let isPostEnded = (expectedMethod == "POST");
Copy link
Member

Choose a reason for hiding this comment

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

It only ends if it's a 301/302/303, right?

Copy link
Contributor Author

@JuniorHsu JuniorHsu Dec 5, 2019

Choose a reason for hiding this comment

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

expectedMethod == "POST" implies it's not 301/302/303

@JuniorHsu
Copy link
Contributor Author

This generally looks okay, but I think we should have coverage for all headers to be removed (and maybe also check that other headers are not removed) and also some arbitrary methods, such as TESTING or some such.

We couldn't do redirecting from/to TESTING.

@JuniorHsu JuniorHsu changed the title Test if we remove Content-(Length|Type) for POST->GET redirects Test if we correctly strip request-body-headers for redirects Dec 6, 2019
@JuniorHsu
Copy link
Contributor Author

After talk to @annevk, we still can send TESTING method for fetch() though it's a little bit weird. I don't test GET->GET redirection. Spec doesn't ask for removing header, but it's weird to have request-body-headers as well.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This looks good to me. I'd prefer asserting actual values where possible and I'd also like the Content-Length test you had before to be reinstated. Even though developers cannot set Content-Length, it still seems good to test that it's properly reset by browsers during redirects. What do you think?

fetch/api/redirect/redirect-method.any.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@JuniorHsu JuniorHsu left a comment

Choose a reason for hiding this comment

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

This looks good to me. I'd prefer asserting actual values where possible and I'd also like the Content-Length test you had before to be reinstated. Even though developers cannot set Content-Length, it still seems good to test that it's properly reset by browsers during redirects. What do you think?

Yeah, let's take Content-Length into account

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This is great, new Content-Length tests end up catching some bugs in Safari. I'll file bugs against Chrome and Safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants