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

Unified Diff: sdk/lib/io/http_headers.dart

Issue 2618523005: Make HTTP headers use a growing buffer, not a fixed-size 8K one. (Closed)
Patch Set: Remove error message and tests expecting it. Created 3 years, 11 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 | « sdk/lib/io/bytes_builder.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_headers.dart
diff --git a/sdk/lib/io/http_headers.dart b/sdk/lib/io/http_headers.dart
index 3769b3f0d04949bb1aa6e1ce5bbfee041ef9aa21..40df48a3c2fd8f739265621310daad4a7094401c 100644
--- a/sdk/lib/io/http_headers.dart
+++ b/sdk/lib/io/http_headers.dart
@@ -465,42 +465,32 @@ class _HttpHeaders implements HttpHeaders {
_mutable = false;
}
- int _write(Uint8List buffer, int offset) {
- void write(List<int> bytes) {
- int len = bytes.length;
- for (int i = 0; i < len; i++) {
- buffer[offset + i] = bytes[i];
- }
- offset += len;
- }
-
- // Format headers.
+ void _build(BytesBuilder builder) {
for (String name in _headers.keys) {
List<String> values = _headers[name];
bool fold = _foldHeader(name);
var nameData = name.codeUnits;
- write(nameData);
- buffer[offset++] = _CharCode.COLON;
- buffer[offset++] = _CharCode.SP;
+ builder.add(nameData);
+ builder.addByte(_CharCode.COLON);
+ builder.addByte(_CharCode.SP);
for (int i = 0; i < values.length; i++) {
if (i > 0) {
if (fold) {
- buffer[offset++] = _CharCode.COMMA;
- buffer[offset++] = _CharCode.SP;
+ builder.addByte(_CharCode.COMMA);
+ builder.addByte(_CharCode.SP);
} else {
- buffer[offset++] = _CharCode.CR;
- buffer[offset++] = _CharCode.LF;
- write(nameData);
- buffer[offset++] = _CharCode.COLON;
- buffer[offset++] = _CharCode.SP;
+ builder.addByte(_CharCode.CR);
+ builder.addByte(_CharCode.LF);
+ builder.add(nameData);
+ builder.addByte(_CharCode.COLON);
+ builder.addByte(_CharCode.SP);
}
}
- write(values[i].codeUnits);
+ builder.add(values[i].codeUnits);
}
- buffer[offset++] = _CharCode.CR;
- buffer[offset++] = _CharCode.LF;
+ builder.addByte(_CharCode.CR);
+ builder.addByte(_CharCode.LF);
}
- return offset;
}
String toString() {
« no previous file with comments | « sdk/lib/io/bytes_builder.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698