Chromium Code Reviews| Index: runtime/bin/http.dart |
| diff --git a/runtime/bin/http.dart b/runtime/bin/http.dart |
| index a3f4931c8dc36a568bc6b6d79fcbfa770e163ff4..e6dfbf193fdb06b859f7ddde6afe2bf7d4bed4eb 100644 |
| --- a/runtime/bin/http.dart |
| +++ b/runtime/bin/http.dart |
| @@ -111,6 +111,12 @@ abstract class HttpServer { |
| * Sets the error handler that is called when a connection error occurs. |
| */ |
| void set onError(void callback(e)); |
| + |
| + /** |
| + * Set the timeout, in seconds, for sessions of this HTTP server. Default |
| + * is 20 minutes. |
| + */ |
| + int set sessionTimeout(int timeout); |
| } |
| @@ -386,6 +392,29 @@ abstract class HeaderValue { |
| String toString(); |
| } |
| +abstract class HttpSession { |
| + /** |
| + * Get the id for the current session. |
| + */ |
| + String get id; |
| + |
| + /** |
| + * Access the user-data associated with the session. |
| + */ |
| + Dynamic data; |
| + |
| + /** |
| + * Destroy the session. This will terminate the session and any further |
| + * connections with this id will be given a new id and session. |
| + */ |
| + void destroy(); |
| + |
| + /** |
| + * Set a callback that will be called when the session is timed out. |
| + */ |
| + void set onTimeout(void callback()); |
| +} |
| + |
| /** |
| * Representation of a content type. |
| @@ -553,11 +582,20 @@ abstract class HttpRequest { |
| HttpHeaders get headers; |
| /** |
| - * Returns the cookies in the request (from the Cookie header). |
| + * Returns the cookies in the request (from the Cookie headers). |
| */ |
| List<Cookie> get cookies; |
| /** |
| + * Returns, or initialize, a session for the given request. If the session is |
| + * being initialized by this call, [initSessions] will be called with the |
| + * newly create session. Here the [:HttpSession.data:] field can be set, if |
| + * needed. |
| + * See [:HttpServer.sessionTimeout:] on how to change default timeout. |
| + */ |
| + 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.
|
| + |
| + /** |
| * Returns the input stream for the request. This is used to read |
| * the request data. |
| */ |