Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Issue 839063005: Allow additional headers for WebSocket connect (Closed)

Created:
5 years, 11 months ago by Søren Gjesse
Modified:
5 years, 11 months ago
CC:
reviews_dartlang.org
Target Ref:
refs/remotes/git-svn
Visibility:
Public.

Description

Allow additional headers for WebSocket connect The WebSocket.connect now takes an Map of headers to add to the initial handshake request. BUG=http://dartbug.com/15855 R=kustermann@google.com, lrn@google.com Committed: https://code.google.com/p/dart/source/detail?r=42870

Patch Set 1 #

Total comments: 20

Patch Set 2 : Changed from callback to passing headers as a Map #

Patch Set 3 : Added Cache-Control header back #

Patch Set 4 : Changed List to Iterable #

Total comments: 21

Patch Set 5 : Addressed review comments #

Patch Set 6 : Rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+81 lines, -20 lines) Patch
M sdk/lib/io/websocket.dart View 1 2 3 4 6 chunks +35 lines, -15 lines 0 comments Download
M sdk/lib/io/websocket_impl.dart View 1 2 3 4 3 chunks +9 lines, -5 lines 0 comments Download
M tests/standalone/io/web_socket_test.dart View 1 4 chunks +37 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Søren Gjesse
5 years, 11 months ago (2015-01-09 14:31:33 UTC) #1
kustermann
I don't really like the way this is handled with a callback - not at ...
5 years, 11 months ago (2015-01-09 14:45:12 UTC) #2
Lasse Reichstein Nielsen
https://codereview.chromium.org/839063005/diff/1/sdk/lib/io/websocket.dart File sdk/lib/io/websocket.dart (right): https://codereview.chromium.org/839063005/diff/1/sdk/lib/io/websocket.dart#newcode134 sdk/lib/io/websocket.dart:134: * If [onRequest] is provided this function will be ...
5 years, 11 months ago (2015-01-12 15:11:56 UTC) #3
Søren Gjesse
PTAL Using the callback was not a good choice. Changed to a Map of additional ...
5 years, 11 months ago (2015-01-12 15:36:34 UTC) #4
Søren Gjesse
ping
5 years, 11 months ago (2015-01-14 10:13:20 UTC) #5
Lasse Reichstein Nielsen
lgtm https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dart File sdk/lib/io/websocket.dart (right): https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dart#newcode71 sdk/lib/io/websocket.dart:71: * request is not a valid web socket ...
5 years, 11 months ago (2015-01-14 10:49:22 UTC) #6
kustermann
lgtm https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket_impl.dart File sdk/lib/io/websocket_impl.dart (right): https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket_impl.dart#newcode804 sdk/lib/io/websocket_impl.dart:804: ..add(HttpHeaders.CONNECTION, "Upgrade") Why is this an .add() and ...
5 years, 11 months ago (2015-01-14 11:42:17 UTC) #7
Søren Gjesse
Committed patchset #6 (id:100001) manually as 42870 (presubmit successful).
5 years, 11 months ago (2015-01-14 13:43:52 UTC) #8
Søren Gjesse
5 years, 11 months ago (2015-01-14 13:54:27 UTC) #9
Message was sent while issue was closed.
https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dart
File sdk/lib/io/websocket.dart (right):

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:128: * Create a new web socket connection. The URL
supplied in [url]
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> I think "web socket" is usually written "WebSocket". 
> Probably change it everywhere.

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:136: * header and potentially cookies. The key of the
map are the header
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> The key -> The keys.

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:137: * fields and the values are either String or
List<String>.
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> What is an "upgrade request"? Either say something about the underlying
protocol
> or link to an external description.

Changed

the initial upgrade request

to

setting up the connection

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:139: * Even if [headers] is provided, there are a
number of headers
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> Drop the "even" part. Just go directly to the facts.

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:142: * `sec-websocket-key`, `upgrade` and
`sec-websocket-protocol`. If
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> Put the headers in alphabetical order. It looks random now.
> Maybe make it a bullet list?

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:143: * any of these are passed in the `headers` they
will be ignored.
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> add "map" after `headers`. Just "the headers" doesn't sound right.

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket.dar...
sdk/lib/io/websocket.dart:146: {Iterable<String> protocols: const [],
On 2015/01/14 10:49:21, Lasse Reichstein Nielsen wrote:
> I'd use "null" as default, and then do the dispatch inside the function. No
need
> to put the "const []" into the API documentation.

Done.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket_imp...
File sdk/lib/io/websocket_impl.dart (right):

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket_imp...
sdk/lib/io/websocket_impl.dart:804: ..add(HttpHeaders.CONNECTION, "Upgrade")
On 2015/01/14 11:42:17, kustermann wrote:
> Why is this an .add() and not a .set(). 
> 
> If the user supplied a connection header as well, you have 2 of them, right?
> That's not what we want if I see this right.

Good catch.

https://codereview.chromium.org/839063005/diff/60001/sdk/lib/io/websocket_imp...
sdk/lib/io/websocket_impl.dart:809: if (protocols.isNotEmpty) {
On 2015/01/14 10:49:22, Lasse Reichstein Nielsen wrote:
> protocols != null && ...
> (if removing the default value).
> 
> Is the type still correct if "protocols" is just an Iterable, not a List?

Done.

https://codereview.chromium.org/839063005/diff/60001/tests/standalone/io/web_...
File tests/standalone/io/web_socket_test.dart (right):

https://codereview.chromium.org/839063005/diff/60001/tests/standalone/io/web_...
tests/standalone/io/web_socket_test.dart:445: Expect.equals('my-value-1,
my-value-2', header[0]);
On 2015/01/14 11:42:17, kustermann wrote:
> I guess the []-operator on HttpHeaders is automatically merging the headers
with
> ", "?

No, it is so stupid that [] returns one element for each header appearence.

For

  My-Header: value-1
  My-Header: value-2, value-3

headers['my-header'] returns

  ['value-1', 'value-2, value-3']

I am not going to say who the bright person designing this was.

Powered by Google App Engine
This is Rietveld 408576698