| OLD | NEW | 
|---|
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 56  * HTTP server. | 56  * HTTP server. | 
| 57  */ | 57  */ | 
| 58 abstract class HttpServer { | 58 abstract class HttpServer { | 
| 59   factory HttpServer() => new _HttpServer(); | 59   factory HttpServer() => new _HttpServer(); | 
| 60 | 60 | 
| 61   /** | 61   /** | 
| 62    * Start listening for HTTP requests on the specified [host] and | 62    * Start listening for HTTP requests on the specified [host] and | 
| 63    * [port]. If a [port] of 0 is specified the server will choose an | 63    * [port]. If a [port] of 0 is specified the server will choose an | 
| 64    * ephemeral port. The optional argument [backlog] can be used to | 64    * ephemeral port. The optional argument [backlog] can be used to | 
| 65    * specify the listen backlog for the underlying OS listen. | 65    * specify the listen backlog for the underlying OS listen. | 
| 66    * The optional argument [certificate_name] is used by the HttpsServer | 66    * The optional arguments [certificate_name] and [requestClientCertificate] | 
| 67    * class, which shares the same interface. | 67    * are used by the HttpsServer class, which shares the same interface. | 
| 68    * See [addRequestHandler] and [defaultRequestHandler] for | 68    * See [addRequestHandler] and [defaultRequestHandler] for | 
| 69    * information on how incoming HTTP requests are handled. | 69    * information on how incoming HTTP requests are handled. | 
| 70    */ | 70    */ | 
| 71   void listen(String host, | 71   void listen(String host, | 
| 72               int port, | 72               int port, | 
| 73               {int backlog: 128, | 73               {int backlog: 128, | 
| 74               String certificate_name}); | 74                String certificate_name, | 
|  | 75                bool requestClientCertificate: false}); | 
| 75 | 76 | 
| 76   /** | 77   /** | 
| 77    * Attach the HTTP server to an existing [:ServerSocket:]. If the | 78    * Attach the HTTP server to an existing [:ServerSocket:]. If the | 
| 78    * [HttpServer] is closed, the [HttpServer] will just detach itself, | 79    * [HttpServer] is closed, the [HttpServer] will just detach itself, | 
| 79    * and not close [serverSocket]. | 80    * and not close [serverSocket]. | 
| 80    */ | 81    */ | 
| 81   void listenOn(ServerSocket serverSocket); | 82   void listenOn(ServerSocket serverSocket); | 
| 82 | 83 | 
| 83   /** | 84   /** | 
| 84    * Adds a request handler to the list of request handlers. The | 85    * Adds a request handler to the list of request handlers. The | 
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 630    * Returns the request headers. | 631    * Returns the request headers. | 
| 631    */ | 632    */ | 
| 632   HttpHeaders get headers; | 633   HttpHeaders get headers; | 
| 633 | 634 | 
| 634   /** | 635   /** | 
| 635    * Returns the cookies in the request (from the Cookie headers). | 636    * Returns the cookies in the request (from the Cookie headers). | 
| 636    */ | 637    */ | 
| 637   List<Cookie> get cookies; | 638   List<Cookie> get cookies; | 
| 638 | 639 | 
| 639   /** | 640   /** | 
|  | 641    * Returns the client certificate of the client making the request. | 
|  | 642    * Returns null if the connection is not a secure TLS or SSL connection, | 
|  | 643    * or if the server does not request a client certificate, or if the client | 
|  | 644    * does not provide one. | 
|  | 645    */ | 
|  | 646   X509Certificate get certificate; | 
|  | 647 | 
|  | 648   /** | 
| 640    * Returns, or initialize, a session for the given request. If the session is | 649    * Returns, or initialize, a session for the given request. If the session is | 
| 641    * being initialized by this call, [init] will be called with the | 650    * being initialized by this call, [init] will be called with the | 
| 642    * newly create session. Here the [:HttpSession.data:] field can be set, if | 651    * newly create session. Here the [:HttpSession.data:] field can be set, if | 
| 643    * needed. | 652    * needed. | 
| 644    * See [:HttpServer.sessionTimeout:] on how to change default timeout. | 653    * See [:HttpServer.sessionTimeout:] on how to change default timeout. | 
| 645    */ | 654    */ | 
| 646   HttpSession session([init(HttpSession session)]); | 655   HttpSession session([init(HttpSession session)]); | 
| 647 | 656 | 
| 648   /** | 657   /** | 
| 649    * Returns the input stream for the request. This is used to read | 658    * Returns the input stream for the request. This is used to read | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 814    * continue normally. | 823    * continue normally. | 
| 815    */ | 824    */ | 
| 816   set authenticate(Future<bool> f(Uri url, String scheme, String realm)); | 825   set authenticate(Future<bool> f(Uri url, String scheme, String realm)); | 
| 817 | 826 | 
| 818   /** | 827   /** | 
| 819    * Add credentials to be used for authorizing HTTP requests. | 828    * Add credentials to be used for authorizing HTTP requests. | 
| 820    */ | 829    */ | 
| 821   void addCredentials(Uri url, String realm, HttpClientCredentials credentials); | 830   void addCredentials(Uri url, String realm, HttpClientCredentials credentials); | 
| 822 | 831 | 
| 823   /** | 832   /** | 
|  | 833    * If [sendClientCertificate] is set to true, authenticate with a client | 
|  | 834    * certificate when connecting with an HTTPS server that requests one. | 
|  | 835    * Select the certificate from the certificate database that matches | 
|  | 836    * the authorities listed by the HTTPS server as valid. | 
|  | 837    * If [clientCertificate] is set, send the certificate with that nickname | 
|  | 838    * instead. | 
|  | 839    */ | 
|  | 840   set sendClientCertificate(bool send); | 
|  | 841 | 
|  | 842   /** | 
|  | 843    * If [clientCertificate] is non-null and [sendClientCertificate] is true, | 
|  | 844    * use [clientCertificate] to select the certificate to send from the | 
|  | 845    * certificate database, looking it up by its nickname. | 
|  | 846    */ | 
|  | 847   set clientCertificate(String nickname); | 
|  | 848 | 
|  | 849   /** | 
| 824    * Sets the function used to resolve the proxy server to be used for | 850    * Sets the function used to resolve the proxy server to be used for | 
| 825    * opening a HTTP connection to the specified [url]. If this | 851    * opening a HTTP connection to the specified [url]. If this | 
| 826    * function is not set, direct connections will always be used. | 852    * function is not set, direct connections will always be used. | 
| 827    * | 853    * | 
| 828    * The string returned by [f] must be in the format used by browser | 854    * The string returned by [f] must be in the format used by browser | 
| 829    * PAC (proxy auto-config) scripts. That is either | 855    * PAC (proxy auto-config) scripts. That is either | 
| 830    * | 856    * | 
| 831    *   "DIRECT" | 857    *   "DIRECT" | 
| 832    * | 858    * | 
| 833    * for using a direct connection or | 859    * for using a direct connection or | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1029    * Returns the response headers. | 1055    * Returns the response headers. | 
| 1030    */ | 1056    */ | 
| 1031   HttpHeaders get headers; | 1057   HttpHeaders get headers; | 
| 1032 | 1058 | 
| 1033   /** | 1059   /** | 
| 1034    * Cookies set by the server (from the Set-Cookie header). | 1060    * Cookies set by the server (from the Set-Cookie header). | 
| 1035    */ | 1061    */ | 
| 1036   List<Cookie> get cookies; | 1062   List<Cookie> get cookies; | 
| 1037 | 1063 | 
| 1038   /** | 1064   /** | 
|  | 1065    * Returns the certificate of the HTTPS server providing the response. | 
|  | 1066    * Returns null if the connection is not a secure TLS or SSL connection. | 
|  | 1067    */ | 
|  | 1068   X509Certificate get certificate; | 
|  | 1069 | 
|  | 1070   /** | 
| 1039    * Returns the input stream for the response. This is used to read | 1071    * Returns the input stream for the response. This is used to read | 
| 1040    * the response data. | 1072    * the response data. | 
| 1041    */ | 1073    */ | 
| 1042   InputStream get inputStream; | 1074   InputStream get inputStream; | 
| 1043 } | 1075 } | 
| 1044 | 1076 | 
| 1045 | 1077 | 
| 1046 abstract class HttpClientCredentials { } | 1078 abstract class HttpClientCredentials { } | 
| 1047 | 1079 | 
| 1048 | 1080 | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1125 class RedirectLimitExceededException extends RedirectException { | 1157 class RedirectLimitExceededException extends RedirectException { | 
| 1126   const RedirectLimitExceededException(List<RedirectInfo> redirects) | 1158   const RedirectLimitExceededException(List<RedirectInfo> redirects) | 
| 1127       : super("Redirect limit exceeded", redirects); | 1159       : super("Redirect limit exceeded", redirects); | 
| 1128 } | 1160 } | 
| 1129 | 1161 | 
| 1130 | 1162 | 
| 1131 class RedirectLoopException extends RedirectException { | 1163 class RedirectLoopException extends RedirectException { | 
| 1132   const RedirectLoopException(List<RedirectInfo> redirects) | 1164   const RedirectLoopException(List<RedirectInfo> redirects) | 
| 1133       : super("Redirect loop detected", redirects); | 1165       : super("Redirect loop detected", redirects); | 
| 1134 } | 1166 } | 
| OLD | NEW | 
|---|