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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 userInfo: uri.userInfo, | 805 userInfo: uri.userInfo, |
806 host: uri.host, | 806 host: uri.host, |
807 port: uri.port, | 807 port: uri.port, |
808 path: uri.path, | 808 path: uri.path, |
809 query: uri.query, | 809 query: uri.query, |
810 fragment: uri.fragment); | 810 fragment: uri.fragment); |
811 return _httpClient.openUrl("GET", uri) | 811 return _httpClient.openUrl("GET", uri) |
812 .then((request) { | 812 .then((request) { |
813 // Setup the initial handshake. | 813 // Setup the initial handshake. |
814 request.headers | 814 request.headers |
815 ..add(HttpHeaders.CONNECTION, "upgrade") | 815 ..add(HttpHeaders.CONNECTION, "Upgrade") |
816 ..set(HttpHeaders.UPGRADE, "websocket") | 816 ..set(HttpHeaders.UPGRADE, "websocket") |
817 ..set("Sec-WebSocket-Key", nonce) | 817 ..set("Sec-WebSocket-Key", nonce) |
| 818 ..set("Cache-Control", "no-cache") |
818 ..set("Sec-WebSocket-Version", "13"); | 819 ..set("Sec-WebSocket-Version", "13"); |
819 if (protocols.isNotEmpty) { | 820 if (protocols.isNotEmpty) { |
820 request.headers.add("Sec-WebSocket-Protocol", protocols); | 821 request.headers.add("Sec-WebSocket-Protocol", protocols); |
821 } | 822 } |
822 return request.close(); | 823 return request.close(); |
823 }) | 824 }) |
824 .then((response) { | 825 .then((response) { |
825 void error(String message) { | 826 void error(String message) { |
826 // Flush data. | 827 // Flush data. |
827 response.detachSocket().then((socket) { | 828 response.detachSocket().then((socket) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 (code < WebSocketStatus.NORMAL_CLOSURE || | 975 (code < WebSocketStatus.NORMAL_CLOSURE || |
975 code == WebSocketStatus.RESERVED_1004 || | 976 code == WebSocketStatus.RESERVED_1004 || |
976 code == WebSocketStatus.NO_STATUS_RECEIVED || | 977 code == WebSocketStatus.NO_STATUS_RECEIVED || |
977 code == WebSocketStatus.ABNORMAL_CLOSURE || | 978 code == WebSocketStatus.ABNORMAL_CLOSURE || |
978 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 979 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && |
979 code < WebSocketStatus.RESERVED_1015) || | 980 code < WebSocketStatus.RESERVED_1015) || |
980 (code >= WebSocketStatus.RESERVED_1015 && | 981 (code >= WebSocketStatus.RESERVED_1015 && |
981 code < 3000)); | 982 code < 3000)); |
982 } | 983 } |
983 } | 984 } |
OLD | NEW |