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 // Global constants. | 7 // Global constants. |
8 class _Const { | 8 class _Const { |
9 // Bytes for "HTTP". | 9 // Bytes for "HTTP". |
10 static const HTTP = const [72, 84, 84, 80]; | 10 static const HTTP = const [72, 84, 84, 80]; |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 } | 838 } |
839 | 839 |
840 List<int> readUnparsedData() { | 840 List<int> readUnparsedData() { |
841 if (_buffer == null) return null; | 841 if (_buffer == null) return null; |
842 if (_index == _buffer.length) return null; | 842 if (_index == _buffer.length) return null; |
843 var result = _buffer.sublist(_index); | 843 var result = _buffer.sublist(_index); |
844 _releaseBuffer(); | 844 _releaseBuffer(); |
845 return result; | 845 return result; |
846 } | 846 } |
847 | 847 |
848 _reset() { | 848 void _reset() { |
849 if (_state == _State.UPGRADED) return; | 849 if (_state == _State.UPGRADED) return; |
850 _state = _State.START; | 850 _state = _State.START; |
851 _messageType = _MessageType.UNDETERMINED; | 851 _messageType = _MessageType.UNDETERMINED; |
852 _headerField = new List(); | 852 _headerField = new List(); |
853 _headerValue = new List(); | 853 _headerValue = new List(); |
854 _method_or_status_code = new List(); | 854 _method_or_status_code = new List(); |
855 _uri_or_reason_phrase = new List(); | 855 _uri_or_reason_phrase = new List(); |
856 | 856 |
857 _statusCode = 0; | 857 _statusCode = 0; |
858 | 858 |
859 _httpVersion = _HttpVersion.UNDETERMINED; | 859 _httpVersion = _HttpVersion.UNDETERMINED; |
860 _transferLength = -1; | 860 _transferLength = -1; |
861 _persistentConnection = false; | 861 _persistentConnection = false; |
862 _connectionUpgrade = false; | 862 _connectionUpgrade = false; |
863 _chunked = false; | 863 _chunked = false; |
864 | 864 |
865 _noMessageBody = false; | 865 _noMessageBody = false; |
866 _responseToMethod = null; | 866 _responseToMethod = null; |
867 _remainingContent = -1; | 867 _remainingContent = -1; |
868 | 868 |
869 _headers = null; | 869 _headers = null; |
870 } | 870 } |
871 | 871 |
872 _releaseBuffer() { | 872 void _releaseBuffer() { |
873 _buffer = null; | 873 _buffer = null; |
874 _index = null; | 874 _index = null; |
875 } | 875 } |
876 | 876 |
877 bool _isTokenChar(int byte) { | 877 bool _isTokenChar(int byte) { |
878 return byte > 31 && byte < 128 && !_Const.SEPARATOR_MAP[byte]; | 878 return byte > 31 && byte < 128 && !_Const.SEPARATOR_MAP[byte]; |
879 } | 879 } |
880 | 880 |
881 static List<String> _tokenizeFieldValue(String headerValue) { | 881 static List<String> _tokenizeFieldValue(String headerValue) { |
882 List<String> tokens = new List<String>(); | 882 List<String> tokens = new List<String>(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 void _reportError(error, [stackTrace]) { | 988 void _reportError(error, [stackTrace]) { |
989 if (_socketSubscription != null) _socketSubscription.cancel(); | 989 if (_socketSubscription != null) _socketSubscription.cancel(); |
990 _state = _State.FAILURE; | 990 _state = _State.FAILURE; |
991 _controller.addError(error, stackTrace); | 991 _controller.addError(error, stackTrace); |
992 _controller.close(); | 992 _controller.close(); |
993 } | 993 } |
994 } | 994 } |
OLD | NEW |