-
Notifications
You must be signed in to change notification settings - Fork 362
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
feat: support multiple headers (Replace #1090) #1106
Conversation
Hello, @brianquinlan : Since #1090 had some incorrect changes (almost all in the test files), I created this new PR to replace it. This PR test passes, but one test fails, which does not seem to be caused by this PR: 00:01 +23 -2: test/io/client_test.dart: #send with an invalid URL [E]
Expected: throws (<Instance of 'ClientException'> with `uri`: Uri:<http://http.invalid> and <Instance of 'SocketException'> with `SocketException.toString`: match 'ClientException with SocketException.*, uri=http://http.invalid')
Actual: <Instance of 'Future<IOStreamedResponse>'>
Which: threw ClientException:<ClientException: Connection closed before full header was received, uri=http://http.invalid>
stack package:http/src/io_client.dart 151:7 IOClient.send
which is not an instance of 'SocketException'
package:test_api OutstandingWork.complete |
@brianquinlan Although this PR also implements the Web headers API of the MDN specification, it does not destroy the widely used common interface. It only changes the type, from In short, the usage of previous versions of Headers
String
Iterable<String>
Iterable<(String, String)>
Iterable<Iterable<String>>
Map<String, String>
Map<String, Iterable<String>> As you said at #1090 (comment), Headers are indeed implemented using Seen in final List<(String, String)> _storage; |
This will still break any code that In your previous PR, you wrote that:
According to RFC-2616 section 4.2:
So any implementation that differentiates between repeated fields and comma-separated field values is incorrect. |
Yes, this PR does make breaking changes to the operator [](String key) => get(key);
operator []=(String key, String value) => set(key, value); To achieve compatibility, but if someone is doing Map processing, it will be difficult to allow this situation. Some modifications are needed.
You are right about this position, but it is also wrong, because this is the agreed part of HTTP Protocol Message generate. This is not something that the Something like this is already done in dart:io's Here's a demo of me using this Headers to send the same headers using dart:io So this is not something that the The accusation of |
@medz I don't fully understand you. My point is that, according to RFC 2616, the following message are equivalent:
and
The |
I agree but I don't think that it is worth breaking the existing API to change it. |
True, but it's difficult to implement the functionality of Sorry, I didn't get any useful discussion information from the discussion of #24. But this PR does fix that. In the HTTP protocol message, cookie is a very unique existence. It cannot be cut by But this does not work for cookies. It must be a passed header to be valid. I suggest that we discuss how to achieve this Is it possible to manage this using the |
Why doesn't this work for cookies? By RFC 6265 4.1.1 cookie values may not contain commas. Why doesn't this work with cookies?
That seems reasonable. |
Well, you convinced me. I think this PR is no longer necessary. Its changes are too big and will cause destructive changes to the existing |
@brianquinlan The following is a standard set-cookie template: set-cookie: has_recent_activity=1; path=/; expires=Sat, 06 Jan 2024 03:32:46 GMT; secure; HttpOnly; SameSite=Lax When there are multiple And set-cookie contains Off topic: Maybe this PR is no longer important to me, I spent a day making a replacement for |
Replace:
feat: support multiple headers #1090
I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.