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

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

Issue 65043019: Use a re-usable buffer for writing HTTP headers. This includes a new header limit of 8192 bytes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup. Created 7 years, 1 month 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 | « no previous file | 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 2dac442c20f35cb95cac469ea7dcb615e0b490e2..9197feeb26d1054c734182ca964d9d3f72c29add 100644
--- a/sdk/lib/io/http_headers.dart
+++ b/sdk/lib/io/http_headers.dart
@@ -344,31 +344,36 @@ class _HttpHeaders implements HttpHeaders {
_mutable = false;
}
- _write(BytesBuilder builder) {
- final COLONSP = const [_CharCode.COLON, _CharCode.SP];
- final COMMASP = const [_CharCode.COMMA, _CharCode.SP];
- final CRLF = const [_CharCode.CR, _CharCode.LF];
+ 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.
_headers.forEach((String name, List<String> values) {
bool fold = _foldHeader(name);
var nameData = name.codeUnits;
- builder.add(nameData);
- builder.add(const [_CharCode.COLON, _CharCode.SP]);
+ write(nameData);
+ write(const [_CharCode.COLON, _CharCode.SP]);
for (int i = 0; i < values.length; i++) {
if (i > 0) {
if (fold) {
- builder.add(const [_CharCode.COMMA, _CharCode.SP]);
+ write(const [_CharCode.COMMA, _CharCode.SP]);
} else {
- builder.add(const [_CharCode.CR, _CharCode.LF]);
- builder.add(nameData);
- builder.add(const [_CharCode.COLON, _CharCode.SP]);
+ write(const [_CharCode.CR, _CharCode.LF]);
+ write(nameData);
+ write(const [_CharCode.COLON, _CharCode.SP]);
}
}
- builder.add(values[i].codeUnits);
+ write(values[i].codeUnits);
}
- builder.add(const [_CharCode.CR, _CharCode.LF]);
+ write(const [_CharCode.CR, _CharCode.LF]);
});
+ return offset;
}
String toString() {
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698