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

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

Issue 11565046: Don't log a user's credentials. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a bug. Created 8 years 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 | « no previous file | utils/pub/oauth2.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 /** 5 /**
6 * Helper functionality to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 library io; 8 library io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return "Read $path. Contents:\n$contents"; 97 return "Read $path. Contents:\n$contents";
98 } else { 98 } else {
99 return "Read ${contents.length} characters from $path."; 99 return "Read ${contents.length} characters from $path.";
100 } 100 }
101 }); 101 });
102 } 102 }
103 103
104 /** 104 /**
105 * Creates [file] (which can either be a [String] or a [File]), and writes 105 * Creates [file] (which can either be a [String] or a [File]), and writes
106 * [contents] to it. Completes when the file is written and closed. 106 * [contents] to it. Completes when the file is written and closed.
107 *
108 * If [dontLogContents] is true, the contents of the file will never be logged.
107 */ 109 */
108 Future<File> writeTextFile(file, String contents) { 110 Future<File> writeTextFile(file, String contents, {dontLogContents: false}) {
Bob Nystrom 2012/12/14 22:22:01 How about: logContents: true
nweiz 2012/12/14 22:29:53 I'm not a big fan of the double negative here eith
109 var path = _getPath(file); 111 var path = _getPath(file);
110 file = new File(path); 112 file = new File(path);
111 113
112 // Sanity check: don't spew a huge file. 114 // Sanity check: don't spew a huge file.
113 log.io("Writing ${contents.length} characters to text file $path."); 115 log.io("Writing ${contents.length} characters to text file $path.");
114 if (contents.length < 1024 * 1024) { 116 if (!dontLogContents && contents.length < 1024 * 1024) {
115 log.fine("Contents:\n$contents"); 117 log.fine("Contents:\n$contents");
116 } 118 }
117 119
118 return file.open(FileMode.WRITE).chain((opened) { 120 return file.open(FileMode.WRITE).chain((opened) {
119 return opened.writeString(contents).chain((ignore) { 121 return opened.writeString(contents).chain((ignore) {
120 return opened.close().transform((_) { 122 return opened.close().transform((_) {
121 log.fine("Wrote text file $path."); 123 log.fine("Wrote text file $path.");
122 return file; 124 return file;
123 }); 125 });
124 }); 126 });
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 /// An HTTP client that transforms 40* errors and socket exceptions into more 512 /// An HTTP client that transforms 40* errors and socket exceptions into more
511 /// user-friendly error messages. 513 /// user-friendly error messages.
512 class PubHttpClient extends http.BaseClient { 514 class PubHttpClient extends http.BaseClient {
513 final http.Client _inner; 515 final http.Client _inner;
514 516
515 PubHttpClient([http.Client inner]) 517 PubHttpClient([http.Client inner])
516 : _inner = inner == null ? new http.Client() : inner; 518 : _inner = inner == null ? new http.Client() : inner;
517 519
518 Future<http.StreamedResponse> send(http.BaseRequest request) { 520 Future<http.StreamedResponse> send(http.BaseRequest request) {
519 log.io("Sending HTTP request $request."); 521 log.io("Sending HTTP request $request.");
520 // TODO(rnystrom): Log request body when it's available and plaintext. 522 // TODO(rnystrom): Log request body when it's available and plaintext, but
523 // not when it contains OAuth2 credentials.
521 524
522 // TODO(nweiz): remove this when issue 4061 is fixed. 525 // TODO(nweiz): remove this when issue 4061 is fixed.
523 var stackTrace; 526 var stackTrace;
524 try { 527 try {
525 throw null; 528 throw null;
526 } catch (_, localStackTrace) { 529 } catch (_, localStackTrace) {
527 stackTrace = localStackTrace; 530 stackTrace = localStackTrace;
528 } 531 }
529 532
530 // TODO(nweiz): Ideally the timeout would extend to reading from the 533 // TODO(nweiz): Ideally the timeout would extend to reading from the
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 return new Directory(entry); 1070 return new Directory(entry);
1068 } 1071 }
1069 1072
1070 /** 1073 /**
1071 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 1074 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
1072 */ 1075 */
1073 Uri _getUri(uri) { 1076 Uri _getUri(uri) {
1074 if (uri is Uri) return uri; 1077 if (uri is Uri) return uri;
1075 return new Uri.fromString(uri); 1078 return new Uri.fromString(uri);
1076 } 1079 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698