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

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

Issue 196423017: Make BaseRequest.contentType use null rather than -1 as a flag value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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/mock_client.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:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 List<int> bodyBytes, 50 List<int> bodyBytes,
51 int statusCode, 51 int statusCode,
52 {BaseRequest request, 52 {BaseRequest request,
53 Map<String, String> headers: const {}, 53 Map<String, String> headers: const {},
54 bool isRedirect: false, 54 bool isRedirect: false,
55 bool persistentConnection: true, 55 bool persistentConnection: true,
56 String reasonPhrase}) 56 String reasonPhrase})
57 : bodyBytes = toUint8List(bodyBytes), 57 : bodyBytes = toUint8List(bodyBytes),
58 super( 58 super(
59 statusCode, 59 statusCode,
60 bodyBytes.length, 60 contentLength: bodyBytes.length,
61 request: request, 61 request: request,
62 headers: headers, 62 headers: headers,
63 isRedirect: isRedirect, 63 isRedirect: isRedirect,
64 persistentConnection: persistentConnection, 64 persistentConnection: persistentConnection,
65 reasonPhrase: reasonPhrase); 65 reasonPhrase: reasonPhrase);
66 66
67 /// Creates a new HTTP response by waiting for the full body to become 67 /// Creates a new HTTP response by waiting for the full body to become
68 /// available from a [StreamedResponse]. 68 /// available from a [StreamedResponse].
69 static Future<Response> fromStream(StreamedResponse response) { 69 static Future<Response> fromStream(StreamedResponse response) {
70 return response.stream.toBytes().then((body) { 70 return response.stream.toBytes().then((body) {
(...skipping 15 matching lines...) Expand all
86 Encoding _encodingForHeaders(Map<String, String> headers) => 86 Encoding _encodingForHeaders(Map<String, String> headers) =>
87 encodingForCharset(_contentTypeForHeaders(headers).charset); 87 encodingForCharset(_contentTypeForHeaders(headers).charset);
88 88
89 /// Returns the [ContentType] object for the given headers. Defaults to 89 /// Returns the [ContentType] object for the given headers. Defaults to
90 /// `application/octet-stream`. 90 /// `application/octet-stream`.
91 ContentType _contentTypeForHeaders(Map<String, String> headers) { 91 ContentType _contentTypeForHeaders(Map<String, String> headers) {
92 var contentType = headers[HttpHeaders.CONTENT_TYPE]; 92 var contentType = headers[HttpHeaders.CONTENT_TYPE];
93 if (contentType != null) return ContentType.parse(contentType); 93 if (contentType != null) return ContentType.parse(contentType);
94 return new ContentType("application", "octet-stream"); 94 return new ContentType("application", "octet-stream");
95 } 95 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/mock_client.dart ('k') | pkg/http/lib/src/streamed_response.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698