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

Side by Side Diff: samples/chat/chat_server_lib.dart

Issue 10008083: Add HTTP/1.0 support and simplify persistent connections handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 #library("chat_server"); 5 #library("chat_server");
6 #import("dart:io"); 6 #import("dart:io");
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 #import("dart:json"); 8 #import("dart:json");
9 9
10 typedef void RequestHandler(HttpRequest request, HttpResponse response); 10 typedef void RequestHandler(HttpRequest request, HttpResponse response);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 String extension = fileName.substring(lastDot); 368 String extension = fileName.substring(lastDot);
369 if (extension == ".css") { mimeType = "text/css"; } 369 if (extension == ".css") { mimeType = "text/css"; }
370 if (extension == ".js") { mimeType = "application/javascript"; } 370 if (extension == ".js") { mimeType = "application/javascript"; }
371 if (extension == ".ico") { mimeType = "image/vnd.microsoft.icon"; } 371 if (extension == ".ico") { mimeType = "image/vnd.microsoft.icon"; }
372 if (extension == ".png") { mimeType = "image/png"; } 372 if (extension == ".png") { mimeType = "image/png"; }
373 } 373 }
374 response.setHeader("Content-Type", mimeType); 374 response.setHeader("Content-Type", mimeType);
375 // Get the length of the file for setting the Content-Length header. 375 // Get the length of the file for setting the Content-Length header.
376 RandomAccessFile openedFile = file.openSync(); 376 RandomAccessFile openedFile = file.openSync();
377 response.contentLength = openedFile.lengthSync(); 377 response.contentLength = openedFile.lengthSync();
378 openedFile.close(); 378 openedFile.closeSync();
379 // Pipe the file content into the response. 379 // Pipe the file content into the response.
380 file.openInputStreamSync().pipe(response.outputStream); 380 file.openInputStream().pipe(response.outputStream);
381 } else { 381 } else {
382 print("File not found: $fileName"); 382 print("File not found: $fileName");
383 _notFoundHandler(request, response); 383 _notFoundHandler(request, response);
384 } 384 }
385 } 385 }
386 386
387 // Serve the not found page. 387 // Serve the not found page.
388 void _notFoundHandler(HttpRequest request, HttpResponse response) { 388 void _notFoundHandler(HttpRequest request, HttpResponse response) {
389 if (_notFoundPage == null) { 389 if (_notFoundPage == null) {
390 _notFoundPage = notFoundPageHtml.charCodes(); 390 _notFoundPage = notFoundPageHtml.charCodes();
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 } 709 }
710 } 710 }
711 711
712 int _timeRange; 712 int _timeRange;
713 List<int> _buckets; 713 List<int> _buckets;
714 int _currentBucket; 714 int _currentBucket;
715 int _currentBucketTime; 715 int _currentBucketTime;
716 num _bucketTimeRange; 716 num _bucketTimeRange;
717 int _sum; 717 int _sum;
718 } 718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698