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

Side by Side Diff: runtime/bin/http_parser.dart

Issue 10379018: Revert "Revert "Implement {Int,Uint}{8,16,32,64} and Float{32,64} typed arrays."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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 // Global constants. 5 // Global constants.
6 class _Const { 6 class _Const {
7 // Bytes for "HTTP". 7 // Bytes for "HTTP".
8 static final HTTP = const [72, 84, 84, 80]; 8 static final HTTP = const [72, 84, 84, 80];
9 // Bytes for "HTTP/1.". 9 // Bytes for "HTTP/1.".
10 static final HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46]; 10 static final HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46];
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 case _State.CHUNKED_BODY_DONE_LF: 491 case _State.CHUNKED_BODY_DONE_LF:
492 _expect(byte, _CharCode.LF); 492 _expect(byte, _CharCode.LF);
493 _bodyEnd(); 493 _bodyEnd();
494 _reset(); 494 _reset();
495 break; 495 break;
496 496
497 case _State.BODY: 497 case _State.BODY:
498 // The body is not handled one byte at a time but in blocks. 498 // The body is not handled one byte at a time but in blocks.
499 int dataAvailable = lastIndex - index; 499 int dataAvailable = lastIndex - index;
500 ByteArray data; 500 List<int> data;
501 if (_remainingContent == null || 501 if (_remainingContent == null ||
502 dataAvailable <= _remainingContent) { 502 dataAvailable <= _remainingContent) {
503 data = new ByteArray(dataAvailable); 503 data = new Uint8List(dataAvailable);
504 data.setRange(0, dataAvailable, buffer, index); 504 data.setRange(0, dataAvailable, buffer, index);
505 } else { 505 } else {
506 data = new ByteArray(_remainingContent); 506 data = new Uint8List(_remainingContent);
507 data.setRange(0, _remainingContent, buffer, index); 507 data.setRange(0, _remainingContent, buffer, index);
508 } 508 }
509 509
510 if (dataReceived != null) dataReceived(data); 510 if (dataReceived != null) dataReceived(data);
511 if (_remainingContent != null) { 511 if (_remainingContent != null) {
512 _remainingContent -= data.length; 512 _remainingContent -= data.length;
513 } 513 }
514 index += data.length; 514 index += data.length;
515 if (_remainingContent == 0) { 515 if (_remainingContent == 0) {
516 if (!_chunked) { 516 if (!_chunked) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 Function dataEnd; 709 Function dataEnd;
710 Function error; 710 Function error;
711 } 711 }
712 712
713 713
714 class HttpParserException implements Exception { 714 class HttpParserException implements Exception {
715 const HttpParserException([String this.message = ""]); 715 const HttpParserException([String this.message = ""]);
716 String toString() => "HttpParserException: $message"; 716 String toString() => "HttpParserException: $message";
717 final String message; 717 final String message;
718 } 718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698