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

Add fetch upload test on HTTP 421 response. #27322

Merged
merged 5 commits into from
Mar 5, 2021

Conversation

yoichio
Copy link
Contributor

@yoichio yoichio commented Jan 26, 2021

Following whatwg/fetch#982,
fetch upload streaming on 421 (Misdirected Request) should be rejected.

@yutakahirano
Copy link
Contributor

Don't we need a test for a non streaming request?

@yoichio
Copy link
Contributor Author

yoichio commented Jan 26, 2021

I think so, but how might we test that requests should be sent twice?

@yutakahirano
Copy link
Contributor

@yoichio
Copy link
Contributor Author

yoichio commented Jan 27, 2021

Added a test for a non streaming request.

Copy link
Contributor

@yutakahirano yutakahirano left a comment

Choose a reason for hiding this comment

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

LGTM. It's difficult to check the connection identity.

@annevk
Copy link
Member

annevk commented Jan 28, 2021

We should also test the service worker responding with with this status code.

@yoichio
Copy link
Contributor Author

yoichio commented Feb 2, 2021

Added service worker test.

@annevk
Copy link
Member

annevk commented Feb 2, 2021

@yoichio in #24965 @MattMenke2 added connection tests and I suspect you could use similar infrastructure here to determine that the connection was not reused.

@yoichio
Copy link
Contributor Author

yoichio commented Feb 3, 2021

Used network-partition-key.py to check connection reuse.
However, it seems Chrome reuses at least port id, which the script uses to identify the connection, so the python can not identify if connection is actually reused or not.
@MattMenke2 , any good idea to do that?

@MattMenke2
Copy link
Member

I don't understand the question. I don't know what port id is.

@yoichio
Copy link
Contributor Author

yoichio commented Feb 4, 2021

I want to test if fetch on 421 response retries fetching same request with new connection.
I thought network-partition-key.py could distinguish connections on which each request was sent.

@MattMenke2
Copy link
Member

network-partition-key.py does create a stash containing one entry for each client address+port, and assumes they aren't reused across sockets. OSes typically assign TCP ports in a sequential order (which isn't great...), so client ports are typically not reused for the duration of the test.

There's never a guarantee that a connection will definitely be reused between two requests.

I'm not sure what this test is doing or why it cares about socket reuse, or perhaps I could be of more help.

@yoichio
Copy link
Contributor Author

yoichio commented Feb 4, 2021

Thanks. I'm confused between connection, socket and port.
I don't have strong opinion to reuse network-partition-key.py to confirm the spec behavior.

I'd like to confirm fetch on 421 does retry on new connection in any way.

@MattMenke2
Copy link
Member

I'm not sure exactly what you're trying to do. Your current modifications to network-partition-key.py look to be counting the total number of requests use a particular uuid, across all connections. Do you want to know the total number of requests use a particular connection instead?

@yoichio
Copy link
Contributor Author

yoichio commented Feb 5, 2021

Do you want to know the total number of requests use a particular connection instead?

Yes.

@MattMenke2
Copy link
Member

Do you want to know the total number of requests use a particular connection instead?

Yes.

Sorry for being a bit slow on the uptake.

So "address_key" identifies the connection. So something like ++server_state[address_key + b"connection_count"] should work, assuming you initialize it to 0. Or perhaps better, could make a dictionary for each address key with connection count and partition_id fields, and just increment the count on each use (At least I believe recursive dictionaries work with the API used to store state).

@yoichio
Copy link
Contributor Author

yoichio commented Feb 9, 2021

Thanks.
Updated the test to count # of requests and connections.

@yoichio
Copy link
Contributor Author

yoichio commented Feb 17, 2021

@annevk, could you take a look?

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.

Looks good modulo nit.

@annevk annevk merged commit ef9bff0 into web-platform-tests:master Mar 5, 2021
annevk pushed a commit to whatwg/fetch that referenced this pull request Mar 5, 2021
In particular, with a request body stream, the response will be returned to the caller as we do not support retries with streams.

Tests: web-platform-tests/wpt#27322.
@yoichio yoichio deleted the 421 branch April 21, 2021 06:36
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