| OLD | NEW |
| 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 const int _OUTGOING_BUFFER_SIZE = 8 * 1024; | 7 const int _OUTGOING_BUFFER_SIZE = 8 * 1024; |
| 8 | 8 |
| 9 class _HttpIncoming extends Stream<List<int>> { | 9 class _HttpIncoming extends Stream<List<int>> { |
| 10 final int _transferLength; | 10 final int _transferLength; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // as they must have already been added to the request causing | 357 // as they must have already been added to the request causing |
| 358 // this authenticate response. | 358 // this authenticate response. |
| 359 if (cr.scheme == _AuthenticationScheme.BASIC && !cr.used) { | 359 if (cr.scheme == _AuthenticationScheme.BASIC && !cr.used) { |
| 360 // Credentials where found, prepare for retrying the request. | 360 // Credentials where found, prepare for retrying the request. |
| 361 return retry(); | 361 return retry(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Digest authentication only supports the MD5 algorithm. | 364 // Digest authentication only supports the MD5 algorithm. |
| 365 if (cr.scheme == _AuthenticationScheme.DIGEST && | 365 if (cr.scheme == _AuthenticationScheme.DIGEST && |
| 366 (header.parameters["algorithm"] == null || | 366 (header.parameters["algorithm"] == null || |
| 367 header.parameters["algorithm"].toLowerCase() == "md5")) { | 367 _ASCII.toLowerCase(header.parameters["algorithm"]) == "md5")) { |
| 368 if (cr.nonce == null || cr.nonce == header.parameters["nonce"]) { | 368 if (cr.nonce == null || cr.nonce == header.parameters["nonce"]) { |
| 369 // If the nonce is not set then this is the first authenticate | 369 // If the nonce is not set then this is the first authenticate |
| 370 // response for these credentials. Set up authentication state. | 370 // response for these credentials. Set up authentication state. |
| 371 if (cr.nonce == null) { | 371 if (cr.nonce == null) { |
| 372 cr..nonce = header.parameters["nonce"] | 372 cr..nonce = header.parameters["nonce"] |
| 373 ..algorithm = "MD5" | 373 ..algorithm = "MD5" |
| 374 ..qop = header.parameters["qop"] | 374 ..qop = header.parameters["qop"] |
| 375 ..nonceCount = 0; | 375 ..nonceCount = 0; |
| 376 } | 376 } |
| 377 // Credentials where found, prepare for retrying the request. | 377 // Credentials where found, prepare for retrying the request. |
| 378 return retry(); | 378 return retry(); |
| 379 } else if (header.parameters["stale"] != null && | 379 } else if (header.parameters["stale"] != null && |
| 380 header.parameters["stale"].toLowerCase() == "true") { | 380 _ASCII.toLowerCase(header.parameters["stale"]) == "true") { |
| 381 // If stale is true retry with new nonce. | 381 // If stale is true retry with new nonce. |
| 382 cr.nonce = header.parameters["nonce"]; | 382 cr.nonce = header.parameters["nonce"]; |
| 383 // Credentials where found, prepare for retrying the request. | 383 // Credentials where found, prepare for retrying the request. |
| 384 return retry(); | 384 return retry(); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Ask for more credentials if none found or the one found has | 389 // Ask for more credentials if none found or the one found has |
| 390 // already been used. If it has already been used it must now be | 390 // already been used. If it has already been used it must now be |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 bool gzip = false; | 919 bool gzip = false; |
| 920 if (isServerSide) { | 920 if (isServerSide) { |
| 921 var response = outbound; | 921 var response = outbound; |
| 922 if (outbound.headers.chunkedTransferEncoding) { | 922 if (outbound.headers.chunkedTransferEncoding) { |
| 923 List acceptEncodings = | 923 List acceptEncodings = |
| 924 response._httpRequest.headers[HttpHeaders.ACCEPT_ENCODING]; | 924 response._httpRequest.headers[HttpHeaders.ACCEPT_ENCODING]; |
| 925 List contentEncoding = outbound.headers[HttpHeaders.CONTENT_ENCODING]; | 925 List contentEncoding = outbound.headers[HttpHeaders.CONTENT_ENCODING]; |
| 926 if (acceptEncodings != null && | 926 if (acceptEncodings != null && |
| 927 acceptEncodings | 927 acceptEncodings |
| 928 .expand((list) => list.split(",")) | 928 .expand((list) => list.split(",")) |
| 929 .any((encoding) => encoding.trim().toLowerCase() == "gzip") && | 929 .any((encoding) => |
| 930 _ASCII.toLowerCase(encoding.trim()) == "gzip") && |
| 930 contentEncoding == null) { | 931 contentEncoding == null) { |
| 931 outbound.headers.set(HttpHeaders.CONTENT_ENCODING, "gzip"); | 932 outbound.headers.set(HttpHeaders.CONTENT_ENCODING, "gzip"); |
| 932 gzip = true; | 933 gzip = true; |
| 933 } | 934 } |
| 934 } | 935 } |
| 935 if (drainRequest && !response._httpRequest._incoming.hasSubscriber) { | 936 if (drainRequest && !response._httpRequest._incoming.hasSubscriber) { |
| 936 drainFuture = response._httpRequest.drain().catchError((_) {}); | 937 drainFuture = response._httpRequest.drain().catchError((_) {}); |
| 937 } | 938 } |
| 938 } else { | 939 } else { |
| 939 drainRequest = false; | 940 drainRequest = false; |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 class _AuthenticationScheme { | 2343 class _AuthenticationScheme { |
| 2343 final int _scheme; | 2344 final int _scheme; |
| 2344 | 2345 |
| 2345 static const UNKNOWN = const _AuthenticationScheme(-1); | 2346 static const UNKNOWN = const _AuthenticationScheme(-1); |
| 2346 static const BASIC = const _AuthenticationScheme(0); | 2347 static const BASIC = const _AuthenticationScheme(0); |
| 2347 static const DIGEST = const _AuthenticationScheme(1); | 2348 static const DIGEST = const _AuthenticationScheme(1); |
| 2348 | 2349 |
| 2349 const _AuthenticationScheme(this._scheme); | 2350 const _AuthenticationScheme(this._scheme); |
| 2350 | 2351 |
| 2351 factory _AuthenticationScheme.fromString(String scheme) { | 2352 factory _AuthenticationScheme.fromString(String scheme) { |
| 2352 if (scheme.toLowerCase() == "basic") return BASIC; | 2353 scheme = _ASCII.toLowerCase(scheme); |
| 2353 if (scheme.toLowerCase() == "digest") return DIGEST; | 2354 if (scheme == "basic") return BASIC; |
| 2355 if (scheme == "digest") return DIGEST; |
| 2354 return UNKNOWN; | 2356 return UNKNOWN; |
| 2355 } | 2357 } |
| 2356 | 2358 |
| 2357 String toString() { | 2359 String toString() { |
| 2358 if (this == BASIC) return "Basic"; | 2360 if (this == BASIC) return "Basic"; |
| 2359 if (this == DIGEST) return "Digest"; | 2361 if (this == DIGEST) return "Digest"; |
| 2360 return "Unknown"; | 2362 return "Unknown"; |
| 2361 } | 2363 } |
| 2362 } | 2364 } |
| 2363 | 2365 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 const _RedirectInfo(this.statusCode, this.method, this.location); | 2579 const _RedirectInfo(this.statusCode, this.method, this.location); |
| 2578 } | 2580 } |
| 2579 | 2581 |
| 2580 String _getHttpVersion() { | 2582 String _getHttpVersion() { |
| 2581 var version = Platform.version; | 2583 var version = Platform.version; |
| 2582 // Only include major and minor version numbers. | 2584 // Only include major and minor version numbers. |
| 2583 int index = version.indexOf('.', version.indexOf('.') + 1); | 2585 int index = version.indexOf('.', version.indexOf('.') + 1); |
| 2584 version = version.substring(0, index); | 2586 version = version.substring(0, index); |
| 2585 return 'Dart/$version (dart:io)'; | 2587 return 'Dart/$version (dart:io)'; |
| 2586 } | 2588 } |
| OLD | NEW |