Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: pkg/http/lib/src/response.dart

Issue 12045024: Fix map literals from change 17410 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/src/multipart_request.dart ('k') | pkg/http/lib/src/streamed_response.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:scalarlist'; 9 import 'dart:scalarlist';
10 10
(...skipping 13 matching lines...) Expand all
24 /// [Encoding.ISO_8859_1] is used by default, as per [RFC 2616][]. 24 /// [Encoding.ISO_8859_1] is used by default, as per [RFC 2616][].
25 /// 25 ///
26 /// [RFC 2616]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html 26 /// [RFC 2616]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
27 String get body => decodeString(bodyBytes, _encodingForHeaders(headers)); 27 String get body => decodeString(bodyBytes, _encodingForHeaders(headers));
28 28
29 /// Creates a new HTTP response with a string body. 29 /// Creates a new HTTP response with a string body.
30 Response( 30 Response(
31 String body, 31 String body,
32 int statusCode, 32 int statusCode,
33 {BaseRequest request, 33 {BaseRequest request,
34 Map<String, String> headers: const <String, String>{}, 34 Map<String, String> headers: const {},
35 bool isRedirect: false, 35 bool isRedirect: false,
36 bool persistentConnection: true, 36 bool persistentConnection: true,
37 String reasonPhrase}) 37 String reasonPhrase})
38 : this.bytes( 38 : this.bytes(
39 encodeString(body, _encodingForHeaders(headers)), 39 encodeString(body, _encodingForHeaders(headers)),
40 statusCode, 40 statusCode,
41 request: request, 41 request: request,
42 headers: headers, 42 headers: headers,
43 isRedirect: isRedirect, 43 isRedirect: isRedirect,
44 persistentConnection: persistentConnection, 44 persistentConnection: persistentConnection,
45 reasonPhrase: reasonPhrase); 45 reasonPhrase: reasonPhrase);
46 46
47 /// Create a new HTTP response with a byte array body. 47 /// Create a new HTTP response with a byte array body.
48 Response.bytes( 48 Response.bytes(
49 List<int> bodyBytes, 49 List<int> bodyBytes,
50 int statusCode, 50 int statusCode,
51 {BaseRequest request, 51 {BaseRequest request,
52 Map<String, String> headers: const <String, String>{}, 52 Map<String, String> headers: const {},
53 bool isRedirect: false, 53 bool isRedirect: false,
54 bool persistentConnection: true, 54 bool persistentConnection: true,
55 String reasonPhrase}) 55 String reasonPhrase})
56 : bodyBytes = toUint8List(bodyBytes), 56 : bodyBytes = toUint8List(bodyBytes),
57 super( 57 super(
58 statusCode, 58 statusCode,
59 bodyBytes.length, 59 bodyBytes.length,
60 request: request, 60 request: request,
61 headers: headers, 61 headers: headers,
62 isRedirect: isRedirect, 62 isRedirect: isRedirect,
(...skipping 22 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/multipart_request.dart ('k') | pkg/http/lib/src/streamed_response.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698