| OLD | NEW |
| 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 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 8 | 8 |
| 9 // Matches _WebSocketOpcode. | 9 // Matches _WebSocketOpcode. |
| 10 class _WebSocketMessageType { | 10 class _WebSocketMessageType { |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 new StreamController<WebSocket>(sync: true); | 365 new StreamController<WebSocket>(sync: true); |
| 366 final Function _protocolSelector; | 366 final Function _protocolSelector; |
| 367 | 367 |
| 368 _WebSocketTransformerImpl(this._protocolSelector); | 368 _WebSocketTransformerImpl(this._protocolSelector); |
| 369 | 369 |
| 370 Stream<WebSocket> bind(Stream<HttpRequest> stream) { | 370 Stream<WebSocket> bind(Stream<HttpRequest> stream) { |
| 371 stream.listen((request) { | 371 stream.listen((request) { |
| 372 _upgrade(request, _protocolSelector) | 372 _upgrade(request, _protocolSelector) |
| 373 .then((WebSocket webSocket) => _controller.add(webSocket)) | 373 .then((WebSocket webSocket) => _controller.add(webSocket)) |
| 374 .catchError(_controller.addError); | 374 .catchError(_controller.addError); |
| 375 }, onDone: () { |
| 376 _controller.close(); |
| 375 }); | 377 }); |
| 376 | 378 |
| 377 return _controller.stream; | 379 return _controller.stream; |
| 378 } | 380 } |
| 379 | 381 |
| 380 static Future<WebSocket> _upgrade(HttpRequest request, _protocolSelector) { | 382 static Future<WebSocket> _upgrade(HttpRequest request, _protocolSelector) { |
| 381 var response = request.response; | 383 var response = request.response; |
| 382 if (!_isUpgradeRequest(request)) { | 384 if (!_isUpgradeRequest(request)) { |
| 383 // Send error response. | 385 // Send error response. |
| 384 response | 386 response |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 (code < WebSocketStatus.NORMAL_CLOSURE || | 1008 (code < WebSocketStatus.NORMAL_CLOSURE || |
| 1007 code == WebSocketStatus.RESERVED_1004 || | 1009 code == WebSocketStatus.RESERVED_1004 || |
| 1008 code == WebSocketStatus.NO_STATUS_RECEIVED || | 1010 code == WebSocketStatus.NO_STATUS_RECEIVED || |
| 1009 code == WebSocketStatus.ABNORMAL_CLOSURE || | 1011 code == WebSocketStatus.ABNORMAL_CLOSURE || |
| 1010 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 1012 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && |
| 1011 code < WebSocketStatus.RESERVED_1015) || | 1013 code < WebSocketStatus.RESERVED_1015) || |
| 1012 (code >= WebSocketStatus.RESERVED_1015 && | 1014 (code >= WebSocketStatus.RESERVED_1015 && |
| 1013 code < 3000)); | 1015 code < 3000)); |
| 1014 } | 1016 } |
| 1015 } | 1017 } |
| OLD | NEW |