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

Side by Side Diff: sdk/lib/io/http_headers.dart

Issue 2650583005: Revert "Make HTTP headers use a growing buffer, not a fixed-size 8K one." (Closed)
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpHeaders implements HttpHeaders { 7 class _HttpHeaders implements HttpHeaders {
8 final Map<String, List<String>> _headers; 8 final Map<String, List<String>> _headers;
9 final String protocolVersion; 9 final String protocolVersion;
10 10
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 _noFoldingHeaders.indexOf(name) != -1)) { 458 _noFoldingHeaders.indexOf(name) != -1)) {
459 return false; 459 return false;
460 } 460 }
461 return true; 461 return true;
462 } 462 }
463 463
464 void _finalize() { 464 void _finalize() {
465 _mutable = false; 465 _mutable = false;
466 } 466 }
467 467
468 void _build(BytesBuilder builder) { 468 int _write(Uint8List buffer, int offset) {
469 void write(List<int> bytes) {
470 int len = bytes.length;
471 for (int i = 0; i < len; i++) {
472 buffer[offset + i] = bytes[i];
473 }
474 offset += len;
475 }
476
477 // Format headers.
469 for (String name in _headers.keys) { 478 for (String name in _headers.keys) {
470 List<String> values = _headers[name]; 479 List<String> values = _headers[name];
471 bool fold = _foldHeader(name); 480 bool fold = _foldHeader(name);
472 var nameData = name.codeUnits; 481 var nameData = name.codeUnits;
473 builder.add(nameData); 482 write(nameData);
474 builder.addByte(_CharCode.COLON); 483 buffer[offset++] = _CharCode.COLON;
475 builder.addByte(_CharCode.SP); 484 buffer[offset++] = _CharCode.SP;
476 for (int i = 0; i < values.length; i++) { 485 for (int i = 0; i < values.length; i++) {
477 if (i > 0) { 486 if (i > 0) {
478 if (fold) { 487 if (fold) {
479 builder.addByte(_CharCode.COMMA); 488 buffer[offset++] = _CharCode.COMMA;
480 builder.addByte(_CharCode.SP); 489 buffer[offset++] = _CharCode.SP;
481 } else { 490 } else {
482 builder.addByte(_CharCode.CR); 491 buffer[offset++] = _CharCode.CR;
483 builder.addByte(_CharCode.LF); 492 buffer[offset++] = _CharCode.LF;
484 builder.add(nameData); 493 write(nameData);
485 builder.addByte(_CharCode.COLON); 494 buffer[offset++] = _CharCode.COLON;
486 builder.addByte(_CharCode.SP); 495 buffer[offset++] = _CharCode.SP;
487 } 496 }
488 } 497 }
489 builder.add(values[i].codeUnits); 498 write(values[i].codeUnits);
490 } 499 }
491 builder.addByte(_CharCode.CR); 500 buffer[offset++] = _CharCode.CR;
492 builder.addByte(_CharCode.LF); 501 buffer[offset++] = _CharCode.LF;
493 } 502 }
503 return offset;
494 } 504 }
495 505
496 String toString() { 506 String toString() {
497 StringBuffer sb = new StringBuffer(); 507 StringBuffer sb = new StringBuffer();
498 _headers.forEach((String name, List<String> values) { 508 _headers.forEach((String name, List<String> values) {
499 sb..write(name)..write(": "); 509 sb..write(name)..write(": ");
500 bool fold = _foldHeader(name); 510 bool fold = _foldHeader(name);
501 for (int i = 0; i < values.length; i++) { 511 for (int i = 0; i < values.length; i++) {
502 if (i > 0) { 512 if (i > 0) {
503 if (fold) { 513 if (fold) {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 (codeUnit >= 0x23 && codeUnit <= 0x2B) || 990 (codeUnit >= 0x23 && codeUnit <= 0x2B) ||
981 (codeUnit >= 0x2D && codeUnit <= 0x3A) || 991 (codeUnit >= 0x2D && codeUnit <= 0x3A) ||
982 (codeUnit >= 0x3C && codeUnit <= 0x5B) || 992 (codeUnit >= 0x3C && codeUnit <= 0x5B) ||
983 (codeUnit >= 0x5D && codeUnit <= 0x7E))) { 993 (codeUnit >= 0x5D && codeUnit <= 0x7E))) {
984 throw new FormatException( 994 throw new FormatException(
985 "Invalid character in cookie value, code unit: '$codeUnit'"); 995 "Invalid character in cookie value, code unit: '$codeUnit'");
986 } 996 }
987 } 997 }
988 } 998 }
989 } 999 }
OLDNEW
« 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