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

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

Issue 11175030: Add sessions to HttpServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 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 /** 5 /**
6 * HTTP status codes. 6 * HTTP status codes.
7 */ 7 */
8 abstract class HttpStatus { 8 abstract class HttpStatus {
9 static const int CONTINUE = 100; 9 static const int CONTINUE = 100;
10 static const int SWITCHING_PROTOCOLS = 101; 10 static const int SWITCHING_PROTOCOLS = 101;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 * Returns the port that the server is listening on. This can be 104 * Returns the port that the server is listening on. This can be
105 * used to get the actual port used when a value of 0 for [port] is 105 * used to get the actual port used when a value of 0 for [port] is
106 * specified in the [listen] call. 106 * specified in the [listen] call.
107 */ 107 */
108 int get port; 108 int get port;
109 109
110 /** 110 /**
111 * Sets the error handler that is called when a connection error occurs. 111 * Sets the error handler that is called when a connection error occurs.
112 */ 112 */
113 void set onError(void callback(e)); 113 void set onError(void callback(e));
114
115 /**
116 * Set the timeout, in seconds, for sessions of this HTTP server. Default
117 * is 20 minutes.
118 */
119 int set sessionTimeout(int timeout);
114 } 120 }
115 121
116 122
117 /** 123 /**
118 * Access to the HTTP headers for requests and responses. In some 124 * Access to the HTTP headers for requests and responses. In some
119 * situations the headers will be imutable and the mutating methods 125 * situations the headers will be imutable and the mutating methods
120 * will then throw exceptions. 126 * will then throw exceptions.
121 * 127 *
122 * For all operation on HTTP headers the header name is 128 * For all operation on HTTP headers the header name is
123 * case-insensitive. 129 * case-insensitive.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 Map<String, String> get parameters; 385 Map<String, String> get parameters;
380 386
381 /** 387 /**
382 * Returns the formatted string representation in the form: 388 * Returns the formatted string representation in the form:
383 * 389 *
384 * value; parameter1=value1; parameter2=value2 390 * value; parameter1=value1; parameter2=value2
385 */ 391 */
386 String toString(); 392 String toString();
387 } 393 }
388 394
395 abstract class HttpSession {
396 /**
397 * Get the id for the current session.
398 */
399 String get id;
400
401 /**
402 * Access the user-data associated with the session.
403 */
404 Dynamic data;
405
406 /**
407 * Destroy the session. This will terminate the session and any further
408 * connections with this id will be given a new id and session.
409 */
410 void destroy();
411
412 /**
413 * Set a callback that will be called when the session is timed out.
414 */
415 void set onTimeout(void callback());
416 }
417
389 418
390 /** 419 /**
391 * Representation of a content type. 420 * Representation of a content type.
392 */ 421 */
393 abstract class ContentType implements HeaderValue { 422 abstract class ContentType implements HeaderValue {
394 /** 423 /**
395 * Creates a new content type object setting the primary type and 424 * Creates a new content type object setting the primary type and
396 * sub type. 425 * sub type.
397 */ 426 */
398 factory ContentType([String primaryType = "", String subType = ""]) { 427 factory ContentType([String primaryType = "", String subType = ""]) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 * Returns the parsed query string. 575 * Returns the parsed query string.
547 */ 576 */
548 Map<String, String> get queryParameters; 577 Map<String, String> get queryParameters;
549 578
550 /** 579 /**
551 * Returns the request headers. 580 * Returns the request headers.
552 */ 581 */
553 HttpHeaders get headers; 582 HttpHeaders get headers;
554 583
555 /** 584 /**
556 * Returns the cookies in the request (from the Cookie header). 585 * Returns the cookies in the request (from the Cookie headers).
557 */ 586 */
558 List<Cookie> get cookies; 587 List<Cookie> get cookies;
559 588
560 /** 589 /**
590 * Returns, or initialize, a session for the given request. If the session is
591 * being initialized by this call, [initSessions] will be called with the
592 * newly create session. Here the [:HttpSession.data:] field can be set, if
593 * needed.
594 * See [:HttpServer.sessionTimeout:] on how to change default timeout.
595 */
596 HttpSession session([initSessions(HttpSession session)]);
Søren Gjesse 2012/10/22 11:13:02 initSessions -> initSession (or maybe just init).
Anders Johnsen 2012/10/22 12:18:57 Done.
597
598 /**
561 * Returns the input stream for the request. This is used to read 599 * Returns the input stream for the request. This is used to read
562 * the request data. 600 * the request data.
563 */ 601 */
564 InputStream get inputStream; 602 InputStream get inputStream;
565 603
566 /** 604 /**
567 * Returns the HTTP protocol version used in the request. This will 605 * Returns the HTTP protocol version used in the request. This will
568 * be "1.0" or "1.1". 606 * be "1.0" or "1.1".
569 */ 607 */
570 String get protocolVersion; 608 String get protocolVersion;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 class RedirectLimitExceededException extends RedirectException { 1003 class RedirectLimitExceededException extends RedirectException {
966 const RedirectLimitExceededException(List<RedirectInfo> redirects) 1004 const RedirectLimitExceededException(List<RedirectInfo> redirects)
967 : super("Redirect limit exceeded", redirects); 1005 : super("Redirect limit exceeded", redirects);
968 } 1006 }
969 1007
970 1008
971 class RedirectLoopException extends RedirectException { 1009 class RedirectLoopException extends RedirectException {
972 const RedirectLoopException(List<RedirectInfo> redirects) 1010 const RedirectLoopException(List<RedirectInfo> redirects)
973 : super("Redirect loop detected", redirects); 1011 : super("Redirect loop detected", redirects);
974 } 1012 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698