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

Side by Side Diff: sdk/lib/io/http.dart

Issue 1425533010: Update documentation for secure networking classes. Remove certificateName parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Change documentation for HttpServer.bind shared parameter. Created 5 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
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * HTTP status codes. 8 * HTTP status codes.
9 */ 9 */
10 abstract class HttpStatus { 10 abstract class HttpStatus {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * 87 *
88 * The HttpRequest exposes the request headers and provides the request body, 88 * The HttpRequest exposes the request headers and provides the request body,
89 * if it exists, as a Stream of data. If the body is unread, it is drained 89 * if it exists, as a Stream of data. If the body is unread, it is drained
90 * when the server writes to the HttpResponse or closes it. 90 * when the server writes to the HttpResponse or closes it.
91 * 91 *
92 * ## Bind with a secure HTTPS connection 92 * ## Bind with a secure HTTPS connection
93 * 93 *
94 * Use [bindSecure] to create an HTTPS server. 94 * Use [bindSecure] to create an HTTPS server.
95 * 95 *
96 * The server presents a certificate to the client. The certificate 96 * The server presents a certificate to the client. The certificate
97 * chain and the private key are set in the SecurityContext 97 * chain and the private key are set in the [SecurityContext]
98 * object that is passed to [bindSecure]. 98 * object that is passed to [bindSecure].
99 * 99 *
100 * import 'dart:io'; 100 * import 'dart:io';
101 * import "dart:isolate"; 101 * import "dart:isolate";
102 * 102 *
103 * main() { 103 * main() {
104 * SecurityContext context = new SecurityContext(); 104 * SecurityContext context = new SecurityContext();
105 * var chain = 105 * var chain =
106 * Platform.script.resolve('certificates/server_chain.pem') 106 * Platform.script.resolve('certificates/server_chain.pem')
107 * .toFilePath(); 107 * .toFilePath();
108 * var key = 108 * var key =
109 * Platform.script.resolve('certificates/server_key.pem') 109 * Platform.script.resolve('certificates/server_key.pem')
110 * .toFilePath(); 110 * .toFilePath();
111 * context.useCertificateChain(chain); 111 * context.useCertificateChain(chain);
112 * context.usePrivateKey(key, password: 'dartdart'); 112 * context.usePrivateKey(key, password: 'dartdart');
113 * 113 *
114 * HttpServer 114 * HttpServer
115 * .bindSecure(InternetAddress.ANY_IP_V6, 115 * .bindSecure(InternetAddress.ANY_IP_V6,
116 * 443, 116 * 443,
117 * context) 117 * context)
118 * .then((server) { 118 * .then((server) {
119 * server.listen((HttpRequest request) { 119 * server.listen((HttpRequest request) {
120 * request.response.write('Hello, world!'); 120 * request.response.write('Hello, world!');
121 * request.response.close(); 121 * request.response.close();
122 * }); 122 * });
123 * }); 123 * });
124 * } 124 * }
125 * 125 *
126 * The certificates and keys are pem files, which can be created and 126 * The certificates and keys are PEM files, which can be created and
127 * managed with the tools in OpenSSL and BoringSSL. 127 * managed with the tools in OpenSSL.
128 * 128 *
129 * ## Connect to a server socket 129 * ## Connect to a server socket
130 * 130 *
131 * You can use the [listenOn] constructor to attach an HTTP server to 131 * You can use the [listenOn] constructor to attach an HTTP server to
132 * a [ServerSocket]. 132 * a [ServerSocket].
133 * 133 *
134 * import 'dart:io'; 134 * import 'dart:io';
135 * 135 *
136 * main() { 136 * main() {
137 * ServerSocket.bind(InternetAddress.ANY_IP_V6, 80) 137 * ServerSocket.bind(InternetAddress.ANY_IP_V6, 80)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 * 230 *
231 * If [port] has the value [:0:] an ephemeral port will be chosen by 231 * If [port] has the value [:0:] an ephemeral port will be chosen by
232 * the system. The actual port used can be retrieved using the 232 * the system. The actual port used can be retrieved using the
233 * [port] getter. 233 * [port] getter.
234 * 234 *
235 * The optional argument [backlog] can be used to specify the listen 235 * The optional argument [backlog] can be used to specify the listen
236 * backlog for the underlying OS listen setup. If [backlog] has the 236 * backlog for the underlying OS listen setup. If [backlog] has the
237 * value of [:0:] (the default) a reasonable value will be chosen by 237 * value of [:0:] (the default) a reasonable value will be chosen by
238 * the system. 238 * the system.
239 * 239 *
240 * The optional argument [shared] specify whether additional binds 240 * The optional argument [shared] specifies whether additional HttpServer
241 * to the same `address`, `port` and `v6Only` combination is 241 * objects can bind to the same combination of `address`, `port` and `v6Only`.
242 * possible from the same Dart process. If `shared` is `true` and 242 * If `shared` is `true` and more `HttpServer`s from this isolate or other
243 * additional binds are performed, then the incoming connections 243 * isolates are bound to the port, then the incoming connections will be
244 * will be distributed between that set of `HttpServer`s. One way of 244 * distributed among all the bound `HttpServer`s. Connections can be
245 * using this is to have number of isolates between which incoming 245 * distributed over multiple isolates this way.
246 * connections are distributed.
247 */ 246 */
248 static Future<HttpServer> bind(address, 247 static Future<HttpServer> bind(address,
249 int port, 248 int port,
250 {int backlog: 0, 249 {int backlog: 0,
251 bool v6Only: false, 250 bool v6Only: false,
252 bool shared: false}) 251 bool shared: false})
253 => _HttpServer.bind(address, port, backlog, v6Only, shared); 252 => _HttpServer.bind(address, port, backlog, v6Only, shared);
254 253
255 /** 254 /**
256 * The [address] can either be a [String] or an 255 * The [address] can either be a [String] or an
(...skipping 14 matching lines...) Expand all
271 * 270 *
272 * If [port] has the value [:0:] an ephemeral port will be chosen by 271 * If [port] has the value [:0:] an ephemeral port will be chosen by
273 * the system. The actual port used can be retrieved using the 272 * the system. The actual port used can be retrieved using the
274 * [port] getter. 273 * [port] getter.
275 * 274 *
276 * The optional argument [backlog] can be used to specify the listen 275 * The optional argument [backlog] can be used to specify the listen
277 * backlog for the underlying OS listen setup. If [backlog] has the 276 * backlog for the underlying OS listen setup. If [backlog] has the
278 * value of [:0:] (the default) a reasonable value will be chosen by 277 * value of [:0:] (the default) a reasonable value will be chosen by
279 * the system. 278 * the system.
280 * 279 *
281 * The certificate with nickname or distinguished name (DN) [certificateName] 280 * If [requestClientCertificate] is true, the server will
282 * is looked up in the certificate database, and is used as the server
283 * certificate. If [requestClientCertificate] is true, the server will
284 * request clients to authenticate with a client certificate. 281 * request clients to authenticate with a client certificate.
282 * The server will advertise the names of trusted issuers of client
283 * certificates, getting them from [context], where they have been
284 * set using [SecurityContext.setClientAuthorities].
285 * 285 *
286 * The optional argument [shared] specify whether additional binds 286 * The optional argument [shared] specifies whether additional HttpServer
287 * to the same `address`, `port` and `v6Only` combination is 287 * objects can bind to the same combination of `address`, `port` and `v6Only`.
288 * possible from the same Dart process. If `shared` is `true` and 288 * If `shared` is `true` and more `HttpServer`s from this isolate or other
289 * additional binds are performed, then the incoming connections 289 * isolates are bound to the port, then the incoming connections will be
290 * will be distributed between that set of `HttpServer`s. One way of 290 * distributed among all the bound `HttpServer`s. Connections can be
291 * using this is to have number of isolates between which incoming 291 * distributed over multiple isolates this way.
292 * connections are distributed.
293 */ 292 */
294 293
295 static Future<HttpServer> bindSecure(address, 294 static Future<HttpServer> bindSecure(address,
296 int port, 295 int port,
297 SecurityContext context, 296 SecurityContext context,
298 {int backlog: 0, 297 {int backlog: 0,
299 bool v6Only: false, 298 bool v6Only: false,
300 String certificateName,
301 bool requestClientCertificate: false, 299 bool requestClientCertificate: false,
302 bool shared: false}) 300 bool shared: false})
303 => _HttpServer.bindSecure(address, 301 => _HttpServer.bindSecure(address,
304 port, 302 port,
305 context, 303 context,
306 backlog, 304 backlog,
307 v6Only, 305 v6Only,
308 certificateName,
309 requestClientCertificate, 306 requestClientCertificate,
310 shared); 307 shared);
311 308
312 /** 309 /**
313 * Attaches the HTTP server to an existing [ServerSocket]. When the 310 * Attaches the HTTP server to an existing [ServerSocket]. When the
314 * [HttpServer] is closed, the [HttpServer] will just detach itself, 311 * [HttpServer] is closed, the [HttpServer] will just detach itself,
315 * closing current connections but not closing [serverSocket]. 312 * closing current connections but not closing [serverSocket].
316 */ 313 */
317 factory HttpServer.listenOn(ServerSocket serverSocket) 314 factory HttpServer.listenOn(ServerSocket serverSocket)
318 => new _HttpServer.listenOn(serverSocket); 315 => new _HttpServer.listenOn(serverSocket);
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 * return request.close(); 1234 * return request.close();
1238 * }) 1235 * })
1239 * .then((HttpClientResponse response) { 1236 * .then((HttpClientResponse response) {
1240 * // Process the response. 1237 * // Process the response.
1241 * ... 1238 * ...
1242 * }); 1239 * });
1243 * 1240 *
1244 * The future for [HttpClientRequest] is created by methods such as 1241 * The future for [HttpClientRequest] is created by methods such as
1245 * [getUrl] and [open]. 1242 * [getUrl] and [open].
1246 * 1243 *
1244 * ## HTTPS connections
1245 *
1246 * An HttpClient can make HTTPS requests, connecting to a server using
1247 * the TLS (SSL) secure networking protocol. Calling [getUrl] with an
1248 * https: scheme will work automatically, if the server's certificate is
1249 * signed by a well-known root CA (certificate authority) on the list of
1250 * trusted CAs from Mozilla's Firefox browser.
Søren Gjesse 2015/11/02 16:15:35 Are the CA's from Mozilla's Firefox browser?
1251 *
1252 * To add a custom trusted certificate authority, or to send a client
1253 * certificate to servers that request one, pass a [SecurityContext] object
1254 * as the optional [context] argument to the `HttpClient` constructor.
1255 * The desired security options can be set on the [SecurityContext] object.
1256 *
1247 * ## Headers 1257 * ## Headers
1248 * 1258 *
1249 * All HttpClient requests set the following header by default: 1259 * All HttpClient requests set the following header by default:
1250 * 1260 *
1251 * Accept-Encoding: gzip 1261 * Accept-Encoding: gzip
1252 * 1262 *
1253 * This allows the HTTP server to use gzip compression for the body if 1263 * This allows the HTTP server to use gzip compression for the body if
1254 * possible. If this behavior is not desired set the 1264 * possible. If this behavior is not desired set the
1255 * `Accept-Encoding` header to something else. 1265 * `Accept-Encoding` header to something else.
1256 * To turn off gzip compression of the response, clear this header: 1266 * To turn off gzip compression of the response, clear this header:
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 class RedirectException implements HttpException { 2022 class RedirectException implements HttpException {
2013 final String message; 2023 final String message;
2014 final List<RedirectInfo> redirects; 2024 final List<RedirectInfo> redirects;
2015 2025
2016 const RedirectException(this.message, this.redirects); 2026 const RedirectException(this.message, this.redirects);
2017 2027
2018 String toString() => "RedirectException: $message"; 2028 String toString() => "RedirectException: $message";
2019 2029
2020 Uri get uri => redirects.last.location; 2030 Uri get uri => redirects.last.location;
2021 } 2031 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698