OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class _HttpHeaders implements HttpHeaders { | 5 class _HttpHeaders implements HttpHeaders { |
6 _HttpHeaders() : _headers = new Map<String, List<String>>(); | 6 _HttpHeaders() : _headers = new Map<String, List<String>>(); |
7 | 7 |
8 List<String> operator[](String name) { | 8 List<String> operator[](String name) { |
9 name = name.toLowerCase(); | 9 name = name.toLowerCase(); |
10 return _headers[name]; | 10 return _headers[name]; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 _headers._mutable = false; | 320 _headers._mutable = false; |
321 _headers._write(_httpConnection); | 321 _headers._write(_httpConnection); |
322 // Terminate header. | 322 // Terminate header. |
323 return _writeCRLF(); | 323 return _writeCRLF(); |
324 } | 324 } |
325 | 325 |
326 bool _writeHexString(int x) { | 326 bool _writeHexString(int x) { |
327 final List<int> hexDigits = [0x30, 0x31, 0x32, 0x33, 0x34, | 327 final List<int> hexDigits = [0x30, 0x31, 0x32, 0x33, 0x34, |
328 0x35, 0x36, 0x37, 0x38, 0x39, | 328 0x35, 0x36, 0x37, 0x38, 0x39, |
329 0x41, 0x42, 0x43, 0x44, 0x45, 0x46]; | 329 0x41, 0x42, 0x43, 0x44, 0x45, 0x46]; |
330 ByteArray hex = new ByteArray(10); | 330 List<int> hex = new Uint8List(10); |
331 int index = hex.length; | 331 int index = hex.length; |
332 while (x > 0) { | 332 while (x > 0) { |
333 index--; | 333 index--; |
334 hex[index] = hexDigits[x % 16]; | 334 hex[index] = hexDigits[x % 16]; |
335 x = x >> 4; | 335 x = x >> 4; |
336 } | 336 } |
337 return _httpConnection._writeFrom(hex, index, hex.length - index); | 337 return _httpConnection._writeFrom(hex, index, hex.length - index); |
338 } | 338 } |
339 | 339 |
340 bool _writeCRLF() { | 340 bool _writeCRLF() { |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 _closing = true; | 752 _closing = true; |
753 _socket.close(); | 753 _socket.close(); |
754 } | 754 } |
755 | 755 |
756 void _onData() { | 756 void _onData() { |
757 int available = _socket.available(); | 757 int available = _socket.available(); |
758 if (available == 0) { | 758 if (available == 0) { |
759 return; | 759 return; |
760 } | 760 } |
761 | 761 |
762 ByteArray buffer = new ByteArray(available); | 762 List<int> buffer = new Uint8List(available); |
763 int bytesRead = _socket.readList(buffer, 0, available); | 763 int bytesRead = _socket.readList(buffer, 0, available); |
764 if (bytesRead > 0) { | 764 if (bytesRead > 0) { |
765 int parsed = _httpParser.writeList(buffer, 0, bytesRead); | 765 int parsed = _httpParser.writeList(buffer, 0, bytesRead); |
766 if (!_httpParser.upgrade) { | 766 if (!_httpParser.upgrade) { |
767 if (parsed != bytesRead) { | 767 if (parsed != bytesRead) { |
768 if (_socket != null) { | 768 if (_socket != null) { |
769 // TODO(sgjesse): Error handling. | 769 // TODO(sgjesse): Error handling. |
770 _close(); | 770 _close(); |
771 } | 771 } |
772 } | 772 } |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 } | 1534 } |
1535 | 1535 |
1536 | 1536 |
1537 class _DetachedSocket implements DetachedSocket { | 1537 class _DetachedSocket implements DetachedSocket { |
1538 _DetachedSocket(this._socket, this._unparsedData); | 1538 _DetachedSocket(this._socket, this._unparsedData); |
1539 Socket get socket() => _socket; | 1539 Socket get socket() => _socket; |
1540 List<int> get unparsedData() => _unparsedData; | 1540 List<int> get unparsedData() => _unparsedData; |
1541 Socket _socket; | 1541 Socket _socket; |
1542 List<int> _unparsedData; | 1542 List<int> _unparsedData; |
1543 } | 1543 } |
OLD | NEW |