| OLD | NEW |
| 1 // Copyright (c) 2012, 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 // The close queue handles graceful closing of HTTP connections. When | 7 // The close queue handles graceful closing of HTTP connections. When |
| 8 // a connection is added to the queue it will enter a wait state | 8 // a connection is added to the queue it will enter a wait state |
| 9 // waiting for all data written and possibly socket shutdown from | 9 // waiting for all data written and possibly socket shutdown from |
| 10 // peer. | 10 // peer. |
| 11 class _CloseQueue { | 11 class _CloseQueue { |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 } | 1681 } |
| 1682 _redirects.add(redirect); | 1682 _redirects.add(redirect); |
| 1683 _doRetry(redirect); | 1683 _doRetry(redirect); |
| 1684 } | 1684 } |
| 1685 | 1685 |
| 1686 void redirect([String method, Uri url]) { | 1686 void redirect([String method, Uri url]) { |
| 1687 if (method == null) method = _method; | 1687 if (method == null) method = _method; |
| 1688 if (url == null) { | 1688 if (url == null) { |
| 1689 url = new Uri.fromString(_response.headers.value(HttpHeaders.LOCATION)); | 1689 url = new Uri.fromString(_response.headers.value(HttpHeaders.LOCATION)); |
| 1690 } | 1690 } |
| 1691 // Always set the content length to 0 for redirects. |
| 1692 var mutable = _request._headers._mutable; |
| 1693 _request._headers._mutable = true; |
| 1694 _request._headers.contentLength = 0; |
| 1695 _request._headers._mutable = mutable; |
| 1696 _request._bodyBytesWritten = 0; |
| 1691 var redirect = new _RedirectInfo(_response.statusCode, method, url); | 1697 var redirect = new _RedirectInfo(_response.statusCode, method, url); |
| 1692 // The actual redirect is postponed until both response and | 1698 // The actual redirect is postponed until both response and |
| 1693 // request are done. | 1699 // request are done. |
| 1694 assert(_pendingRetry == null); | 1700 assert(_pendingRetry == null); |
| 1695 _pendingRedirect = redirect; | 1701 _pendingRedirect = redirect; |
| 1696 } | 1702 } |
| 1697 | 1703 |
| 1698 List<RedirectInfo> get redirects => _redirects; | 1704 List<RedirectInfo> get redirects => _redirects; |
| 1699 | 1705 |
| 1700 Function _onRequest; | 1706 Function _onRequest; |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2300 | 2306 |
| 2301 | 2307 |
| 2302 class _RedirectInfo implements RedirectInfo { | 2308 class _RedirectInfo implements RedirectInfo { |
| 2303 const _RedirectInfo(int this.statusCode, | 2309 const _RedirectInfo(int this.statusCode, |
| 2304 String this.method, | 2310 String this.method, |
| 2305 Uri this.location); | 2311 Uri this.location); |
| 2306 final int statusCode; | 2312 final int statusCode; |
| 2307 final String method; | 2313 final String method; |
| 2308 final Uri location; | 2314 final Uri location; |
| 2309 } | 2315 } |
| OLD | NEW |