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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/http.dart

Issue 14914002: Change fromString constructor to parse static method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed additional tests Created 7 years, 7 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/oauth2/lib/src/handle_access_token_response.dart ('k') | sdk/lib/io/http.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 /// Helpers for dealing with HTTP. 5 /// Helpers for dealing with HTTP.
6 library pub.http; 6 library pub.http;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:json' as json; 10 import 'dart:json' as json;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 /// Logs the fact that [request] was sent, and information about it. 90 /// Logs the fact that [request] was sent, and information about it.
91 void _logRequest(http.BaseRequest request) { 91 void _logRequest(http.BaseRequest request) {
92 var requestLog = new StringBuffer(); 92 var requestLog = new StringBuffer();
93 requestLog.writeln("HTTP ${request.method} ${request.url}"); 93 requestLog.writeln("HTTP ${request.method} ${request.url}");
94 request.headers.forEach((name, value) => 94 request.headers.forEach((name, value) =>
95 requestLog.writeln(_logField(name, value))); 95 requestLog.writeln(_logField(name, value)));
96 96
97 if (request.method == 'POST') { 97 if (request.method == 'POST') {
98 var contentTypeString = request.headers[HttpHeaders.CONTENT_TYPE]; 98 var contentTypeString = request.headers[HttpHeaders.CONTENT_TYPE];
99 if (contentTypeString == null) contentTypeString = ''; 99 if (contentTypeString == null) contentTypeString = '';
100 var contentType = new ContentType.fromString(contentTypeString); 100 var contentType = ContentType.parse(contentTypeString);
101 if (request is http.MultipartRequest) { 101 if (request is http.MultipartRequest) {
102 requestLog.writeln(); 102 requestLog.writeln();
103 requestLog.writeln("Body fields:"); 103 requestLog.writeln("Body fields:");
104 request.fields.forEach((name, value) => 104 request.fields.forEach((name, value) =>
105 requestLog.writeln(_logField(name, value))); 105 requestLog.writeln(_logField(name, value)));
106 106
107 // TODO(nweiz): make MultipartRequest.files readable, and log them? 107 // TODO(nweiz): make MultipartRequest.files readable, and log them?
108 } else if (request is http.Request) { 108 } else if (request is http.Request) {
109 if (contentType.value == 'application/x-www-form-urlencoded') { 109 if (contentType.value == 'application/x-www-form-urlencoded') {
110 requestLog.writeln(); 110 requestLog.writeln();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 /// Exception thrown when an HTTP operation fails. 201 /// Exception thrown when an HTTP operation fails.
202 class PubHttpException implements Exception { 202 class PubHttpException implements Exception {
203 final http.Response response; 203 final http.Response response;
204 204
205 const PubHttpException(this.response); 205 const PubHttpException(this.response);
206 206
207 String toString() => 'HTTP error ${response.statusCode}: ' 207 String toString() => 'HTTP error ${response.statusCode}: '
208 '${response.reasonPhrase}'; 208 '${response.reasonPhrase}';
209 } 209 }
OLDNEW
« no previous file with comments | « pkg/oauth2/lib/src/handle_access_token_response.dart ('k') | sdk/lib/io/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698