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

Side by Side Diff: utils/pub/http.dart

Issue 12870003: Make argument to StringSink.writeln optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot one use-case. Created 7 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 | « sdk/lib/io/io_sink.dart ('k') | no next file » | 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 var requestLog = new StringBuffer(); 84 var requestLog = new StringBuffer();
85 requestLog.writeln("HTTP ${request.method} ${request.url}"); 85 requestLog.writeln("HTTP ${request.method} ${request.url}");
86 request.headers.forEach((name, value) => 86 request.headers.forEach((name, value) =>
87 requestLog.writeln(_logField(name, value))); 87 requestLog.writeln(_logField(name, value)));
88 88
89 if (request.method == 'POST') { 89 if (request.method == 'POST') {
90 var contentTypeString = request.headers[HttpHeaders.CONTENT_TYPE]; 90 var contentTypeString = request.headers[HttpHeaders.CONTENT_TYPE];
91 if (contentTypeString == null) contentTypeString = ''; 91 if (contentTypeString == null) contentTypeString = '';
92 var contentType = new ContentType.fromString(contentTypeString); 92 var contentType = new ContentType.fromString(contentTypeString);
93 if (contentType.value == 'application/x-www-form-urlencoded') { 93 if (contentType.value == 'application/x-www-form-urlencoded') {
94 requestLog.writeln(''); 94 requestLog.write('');
Søren Gjesse 2013/03/15 11:10:53 writeln()?
floitsch 2013/03/15 12:45:21 Done.
95 requestLog.writeln("Body fields:"); 95 requestLog.writeln("Body fields:");
96 request.bodyFields.forEach((name, value) => 96 request.bodyFields.forEach((name, value) =>
97 requestLog.writeln(_logField(name, value))); 97 requestLog.writeln(_logField(name, value)));
98 } else if (contentType.value == 'text/plain' || 98 } else if (contentType.value == 'text/plain' ||
99 contentType.value == 'application/json') { 99 contentType.value == 'application/json') {
100 requestLog.write(request.body); 100 requestLog.write(request.body);
101 } else if (request is http.MultipartRequest) { 101 } else 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 } 108 }
109 } 109 }
110 110
111 log.fine(requestLog.toString().trim()); 111 log.fine(requestLog.toString().trim());
112 } 112 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 /// Exception thrown when an HTTP operation fails. 192 /// Exception thrown when an HTTP operation fails.
193 class PubHttpException implements Exception { 193 class PubHttpException implements Exception {
194 final http.Response response; 194 final http.Response response;
195 195
196 const PubHttpException(this.response); 196 const PubHttpException(this.response);
197 197
198 String toString() => 'HTTP error ${response.statusCode}: ' 198 String toString() => 'HTTP error ${response.statusCode}: '
199 '${response.reasonPhrase}'; 199 '${response.reasonPhrase}';
200 } 200 }
OLDNEW
« no previous file with comments | « sdk/lib/io/io_sink.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698