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

Unified Diff: lib/src/io_io.dart

Issue 2671243002: Fix bug in readAsString when charset is LATIN-1 and content-length is set. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/io_io.dart
diff --git a/lib/src/io_io.dart b/lib/src/io_io.dart
index 619dfed0afea70ce20b1e210979feb7bb74d95f6..04506515b204444a20e9312e8452b9c7c1b62850 100644
--- a/lib/src/io_io.dart
+++ b/lib/src/io_io.dart
@@ -76,7 +76,8 @@ Future<String> readAsString(Uri uri, Encoding encoding) async {
// Special case LATIN-1 since it is common and doesn't need decoding.
int length = response.contentLength;
if (length < 0) length = 0;
- var buffer = new Uint8Buffer(length);
+ // Create empty buffer with capacity matching contentLength.
+ var buffer = new Uint8Buffer(length)..length = 0;
await for (var bytes in response) {
buffer.addAll(bytes);
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698