| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library shelf.message; | 5 library shelf.message; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:collection/wrappers.dart'; | 10 import 'package:collection/wrappers.dart'; |
| 11 import 'package:http_parser/http_parser.dart'; |
| 11 import 'package:stack_trace/stack_trace.dart'; | 12 import 'package:stack_trace/stack_trace.dart'; |
| 12 | 13 |
| 13 import 'media_type.dart'; | |
| 14 | |
| 15 /// Represents logic shared between [Request] and [Response]. | 14 /// Represents logic shared between [Request] and [Response]. |
| 16 abstract class Message { | 15 abstract class Message { |
| 17 /// The HTTP headers. | 16 /// The HTTP headers. |
| 18 /// | 17 /// |
| 19 /// The value is immutable. | 18 /// The value is immutable. |
| 20 final Map<String, String> headers; | 19 final Map<String, String> headers; |
| 21 | 20 |
| 22 /// The streaming body of the message. | 21 /// The streaming body of the message. |
| 23 /// | 22 /// |
| 24 /// This can be read via [read] or [readAsString]. | 23 /// This can be read via [read] or [readAsString]. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 /// Otherwise the encoding is taken from the Content-Type header. If that | 85 /// Otherwise the encoding is taken from the Content-Type header. If that |
| 87 /// doesn't exist or doesn't have a "charset" parameter, UTF-8 is used. | 86 /// doesn't exist or doesn't have a "charset" parameter, UTF-8 is used. |
| 88 /// | 87 /// |
| 89 /// This calls [read] internally, which can only be called once. | 88 /// This calls [read] internally, which can only be called once. |
| 90 Future<String> readAsString([Encoding encoding]) { | 89 Future<String> readAsString([Encoding encoding]) { |
| 91 if (encoding == null) encoding = this.encoding; | 90 if (encoding == null) encoding = this.encoding; |
| 92 if (encoding == null) encoding = UTF8; | 91 if (encoding == null) encoding = UTF8; |
| 93 return Chain.track(encoding.decodeStream(read())); | 92 return Chain.track(encoding.decodeStream(read())); |
| 94 } | 93 } |
| 95 } | 94 } |
| OLD | NEW |