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 library response; | 5 library response; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:typeddata'; | 9 import 'dart:typed_data'; |
10 | 10 |
11 import 'base_request.dart'; | 11 import 'base_request.dart'; |
12 import 'base_response.dart'; | 12 import 'base_response.dart'; |
13 import 'streamed_response.dart'; | 13 import 'streamed_response.dart'; |
14 import 'utils.dart'; | 14 import 'utils.dart'; |
15 | 15 |
16 /// An HTTP response where the entire response body is known in advance. | 16 /// An HTTP response where the entire response body is known in advance. |
17 class Response extends BaseResponse { | 17 class Response extends BaseResponse { |
18 /// The bytes comprising the body of this response. | 18 /// The bytes comprising the body of this response. |
19 final Uint8List bodyBytes; | 19 final Uint8List bodyBytes; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Encoding _encodingForHeaders(Map<String, String> headers) => | 85 Encoding _encodingForHeaders(Map<String, String> headers) => |
86 encodingForCharset(_contentTypeForHeaders(headers).charset); | 86 encodingForCharset(_contentTypeForHeaders(headers).charset); |
87 | 87 |
88 /// Returns the [ContentType] object for the given headers. Defaults to | 88 /// Returns the [ContentType] object for the given headers. Defaults to |
89 /// `application/octet-stream`. | 89 /// `application/octet-stream`. |
90 ContentType _contentTypeForHeaders(Map<String, String> headers) { | 90 ContentType _contentTypeForHeaders(Map<String, String> headers) { |
91 var contentType = headers[HttpHeaders.CONTENT_TYPE]; | 91 var contentType = headers[HttpHeaders.CONTENT_TYPE]; |
92 if (contentType != null) return new ContentType.fromString(contentType); | 92 if (contentType != null) return new ContentType.fromString(contentType); |
93 return new ContentType("application", "octet-stream"); | 93 return new ContentType("application", "octet-stream"); |
94 } | 94 } |
OLD | NEW |