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 typedef void _BytesConsumer(List<int> bytes); | 9 typedef void _BytesConsumer(List<int> bytes); |
10 | 10 |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 757 |
758 HttpConnectionInfo get connectionInfo => _httpClientConnection.connectionInfo; | 758 HttpConnectionInfo get connectionInfo => _httpClientConnection.connectionInfo; |
759 | 759 |
760 void _onIncoming(_HttpIncoming incoming) { | 760 void _onIncoming(_HttpIncoming incoming) { |
761 var response = new _HttpClientResponse(incoming, this, _httpClient); | 761 var response = new _HttpClientResponse(incoming, this, _httpClient); |
762 Future<HttpClientResponse> future; | 762 Future<HttpClientResponse> future; |
763 if (followRedirects && response.isRedirect) { | 763 if (followRedirects && response.isRedirect) { |
764 if (response.redirects.length < maxRedirects) { | 764 if (response.redirects.length < maxRedirects) { |
765 // Redirect and drain response. | 765 // Redirect and drain response. |
766 future = response.drain() | 766 future = response.drain() |
767 .then/*<HttpClientResponse>*/((_) => response.redirect()); | 767 .then<HttpClientResponse>((_) => response.redirect()); |
768 } else { | 768 } else { |
769 // End with exception, too many redirects. | 769 // End with exception, too many redirects. |
770 future = response.drain() | 770 future = response.drain() |
771 .then/*<HttpClientResponse>*/((_) { | 771 .then<HttpClientResponse>((_) { |
772 return new Future<HttpClientResponse>.error( | 772 return new Future<HttpClientResponse>.error( |
773 new RedirectException("Redirect limit exceeded", | 773 new RedirectException("Redirect limit exceeded", |
774 response.redirects)); | 774 response.redirects)); |
775 }); | 775 }); |
776 } | 776 } |
777 } else if (response._shouldAuthenticateProxy) { | 777 } else if (response._shouldAuthenticateProxy) { |
778 future = response._authenticate(true); | 778 future = response._authenticate(true); |
779 } else if (response._shouldAuthenticate) { | 779 } else if (response._shouldAuthenticate) { |
780 future = response._authenticate(false); | 780 future = response._authenticate(false); |
781 } else { | 781 } else { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 // Look for credentials. | 1384 // Look for credentials. |
1385 creds = _httpClient._findCredentials(uri); | 1385 creds = _httpClient._findCredentials(uri); |
1386 if (creds != null) { | 1386 if (creds != null) { |
1387 creds.authorize(request); | 1387 creds.authorize(request); |
1388 } | 1388 } |
1389 } | 1389 } |
1390 // Start sending the request (lazy, delayed until the user provides | 1390 // Start sending the request (lazy, delayed until the user provides |
1391 // data). | 1391 // data). |
1392 _httpParser.isHead = method == "HEAD"; | 1392 _httpParser.isHead = method == "HEAD"; |
1393 _streamFuture = outgoing.done | 1393 _streamFuture = outgoing.done |
1394 .then/*<Socket>*/((Socket s) { | 1394 .then<Socket>((Socket s) { |
1395 // Request sent, set up response completer. | 1395 // Request sent, set up response completer. |
1396 _nextResponseCompleter = new Completer(); | 1396 _nextResponseCompleter = new Completer(); |
1397 | 1397 |
1398 // Listen for response. | 1398 // Listen for response. |
1399 _nextResponseCompleter.future | 1399 _nextResponseCompleter.future |
1400 .then((incoming) { | 1400 .then((incoming) { |
1401 _currentUri = null; | 1401 _currentUri = null; |
1402 incoming.dataDone.then((closing) { | 1402 incoming.dataDone.then((closing) { |
1403 if (incoming.upgraded) { | 1403 if (incoming.upgraded) { |
1404 _httpClient._connectionClosed(this); | 1404 _httpClient._connectionClosed(this); |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 const _RedirectInfo(this.statusCode, this.method, this.location); | 2891 const _RedirectInfo(this.statusCode, this.method, this.location); |
2892 } | 2892 } |
2893 | 2893 |
2894 String _getHttpVersion() { | 2894 String _getHttpVersion() { |
2895 var version = Platform.version; | 2895 var version = Platform.version; |
2896 // Only include major and minor version numbers. | 2896 // Only include major and minor version numbers. |
2897 int index = version.indexOf('.', version.indexOf('.') + 1); | 2897 int index = version.indexOf('.', version.indexOf('.') + 1); |
2898 version = version.substring(0, index); | 2898 version = version.substring(0, index); |
2899 return 'Dart/$version (dart:io)'; | 2899 return 'Dart/$version (dart:io)'; |
2900 } | 2900 } |
OLD | NEW |