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

Side by Side Diff: sdk/lib/io/websocket.dart

Issue 1584653008: Optimize Websocket compression for no context takeover requests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * WebSocket status codes used when closing a WebSocket connection. 8 * WebSocket status codes used when closing a WebSocket connection.
9 */ 9 */
10 abstract class WebSocketStatus { 10 abstract class WebSocketStatus {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 /// Returns default values for client compression request headers. 110 /// Returns default values for client compression request headers.
111 String _createClientRequestHeader(HeaderValue requested, int size) { 111 String _createClientRequestHeader(HeaderValue requested, int size) {
112 var info = ""; 112 var info = "";
113 113
114 // If responding to a valid request, specify size 114 // If responding to a valid request, specify size
115 if (requested != null) { 115 if (requested != null) {
116 info = "; client_max_window_bits=$size"; 116 info = "; client_max_window_bits=$size";
117 } else { 117 } else {
118 // Client request. Specify default 118 // Client request. Specify default
119 info = "; client_max_window_bits"; 119 if (clientMaxWindowBits == null) {
120 info = "; client_max_window_bits";
121 } else {
122 info = "; client_max_window_bits=$clientMaxWindowBits";
123 }
124 if (serverMaxWindowBits != null) {
125 info += "; server_max_window_bits=$serverMaxWindowBits";
126 }
120 } 127 }
121 128
122 return info; 129 return info;
123 } 130 }
124 131
125 /// Create a Compression Header. If [requested] is null or contains 132 /// Create a Compression Header. If [requested] is null or contains
126 /// client request headers, returns Client compression request headers with 133 /// client request headers, returns Client compression request headers with
127 /// default settings for `client_max_window_bits` header value. 134 /// default settings for `client_max_window_bits` header value.
128 /// If [requested] contains server response headers this method returns 135 /// If [requested] contains server response headers this method returns
129 /// a Server compression response header negotiating the max window bits 136 /// a Server compression response header negotiating the max window bits
130 /// for both client and server as requested server_max_window_bits value. 137 /// for both client and server as requested server_max_window_bits value.
131 /// This method returns a [_CompressionMaxWindowBits] object with the 138 /// This method returns a [_CompressionMaxWindowBits] object with the
132 /// response headers and negotiated maxWindowBits value. 139 /// response headers and negotiated maxWindowBits value.
133 _CompressionMaxWindowBits _createHeader([HeaderValue requested]) { 140 _CompressionMaxWindowBits _createHeader([HeaderValue requested]) {
134 var info = new _CompressionMaxWindowBits("", 0); 141 var info = new _CompressionMaxWindowBits("", 0);
135 if (!enabled) { 142 if (!enabled) {
136 return info; 143 return info;
137 } 144 }
138 145
139 info.headerValue = _WebSocketImpl.PER_MESSAGE_DEFLATE; 146 info.headerValue = _WebSocketImpl.PER_MESSAGE_DEFLATE;
140 147
141 if (clientNoContextTakeover && 148 if (clientNoContextTakeover &&
142 (requested != null && 149 (requested == null || (requested != null &&
143 requested.parameters.containsKey(_clientNoContextTakeover))) { 150 requested.parameters.containsKey(_clientNoContextTakeover)))) {
144 info.headerValue += "; client_no_context_takeover"; 151 info.headerValue += "; client_no_context_takeover";
145 } 152 }
146 153
147 if (serverNoContextTakeover && 154 if (serverNoContextTakeover &&
148 (requested != null && 155 (requested == null || (requested != null &&
149 requested.parameters.containsKey(_serverNoContextTakeover))) { 156 requested.parameters.containsKey(_serverNoContextTakeover)))) {
150 info.headerValue += "; server_no_context_takeover"; 157 info.headerValue += "; server_no_context_takeover";
151 } 158 }
152 159
153 var headerList = _createServerResponseHeader(requested); 160 var headerList = _createServerResponseHeader(requested);
154 info.headerValue += headerList.headerValue; 161 info.headerValue += headerList.headerValue;
155 info.maxWindowBits = headerList.maxWindowBits; 162 info.maxWindowBits = headerList.maxWindowBits;
156 163
157 info.headerValue += 164 info.headerValue +=
158 _createClientRequestHeader(requested, info.maxWindowBits); 165 _createClientRequestHeader(requested, info.maxWindowBits);
159 166
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 Future addStream(Stream stream); 401 Future addStream(Stream stream);
395 } 402 }
396 403
397 class WebSocketException implements IOException { 404 class WebSocketException implements IOException {
398 final String message; 405 final String message;
399 406
400 const WebSocketException([this.message = ""]); 407 const WebSocketException([this.message = ""]);
401 408
402 String toString() => "WebSocketException: $message"; 409 String toString() => "WebSocketException: $message";
403 } 410 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/websocket_impl.dart » ('j') | tests/standalone/io/web_socket_compression_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698