| 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 class _HttpIncoming | 7 class _HttpIncoming |
| 8 extends Stream<List<int>> implements StreamSink<List<int>> { | 8 extends Stream<List<int>> implements StreamSink<List<int>> { |
| 9 final int _transferLength; | 9 final int _transferLength; |
| 10 final Completer _dataCompleter = new Completer(); | 10 final Completer _dataCompleter = new Completer(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 _HttpClientRequest this._httpRequest, | 163 _HttpClientRequest this._httpRequest, |
| 164 _HttpClient this._httpClient) | 164 _HttpClient this._httpClient) |
| 165 : super(_incoming); | 165 : super(_incoming); |
| 166 | 166 |
| 167 int get statusCode => _incoming.statusCode; | 167 int get statusCode => _incoming.statusCode; |
| 168 String get reasonPhrase => _incoming.reasonPhrase; | 168 String get reasonPhrase => _incoming.reasonPhrase; |
| 169 | 169 |
| 170 List<Cookie> get cookies { | 170 List<Cookie> get cookies { |
| 171 if (_cookies != null) return _cookies; | 171 if (_cookies != null) return _cookies; |
| 172 _cookies = new List<Cookie>(); | 172 _cookies = new List<Cookie>(); |
| 173 List<String> values = headers["set-cookie"]; | 173 List<String> values = headers[HttpHeaders.SET_COOKIE]; |
| 174 if (values != null) { | 174 if (values != null) { |
| 175 values.forEach((value) { | 175 values.forEach((value) { |
| 176 _cookies.add(new Cookie.fromSetCookieValue(value)); | 176 _cookies.add(new Cookie.fromSetCookieValue(value)); |
| 177 }); | 177 }); |
| 178 } | 178 } |
| 179 return _cookies; | 179 return _cookies; |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool get isRedirect { | 182 bool get isRedirect { |
| 183 if (_httpRequest.method == "GET" || _httpRequest.method == "HEAD") { | 183 if (_httpRequest.method == "GET" || _httpRequest.method == "HEAD") { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 break; | 459 break; |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 if (!found) { | 462 if (!found) { |
| 463 cookies.add(new Cookie(_DART_SESSION_ID, session.id)..httpOnly = true); | 463 cookies.add(new Cookie(_DART_SESSION_ID, session.id)..httpOnly = true); |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 // Add all the cookies set to the headers. | 466 // Add all the cookies set to the headers. |
| 467 if (_cookies != null) { | 467 if (_cookies != null) { |
| 468 _cookies.forEach((cookie) { | 468 _cookies.forEach((cookie) { |
| 469 headers.add("set-cookie", cookie); | 469 headers.add(HttpHeaders.SET_COOKIE, cookie); |
| 470 }); | 470 }); |
| 471 } | 471 } |
| 472 | 472 |
| 473 headers._finalize(); | 473 headers._finalize(); |
| 474 | 474 |
| 475 // Write headers. | 475 // Write headers. |
| 476 headers._write(this); | 476 headers._write(this); |
| 477 writeCRLF(); | 477 writeCRLF(); |
| 478 } | 478 } |
| 479 | 479 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 650 |
| 651 // Add the cookies to the headers. | 651 // Add the cookies to the headers. |
| 652 if (!cookies.isEmpty) { | 652 if (!cookies.isEmpty) { |
| 653 StringBuffer sb = new StringBuffer(); | 653 StringBuffer sb = new StringBuffer(); |
| 654 for (int i = 0; i < cookies.length; i++) { | 654 for (int i = 0; i < cookies.length; i++) { |
| 655 if (i > 0) sb.add("; "); | 655 if (i > 0) sb.add("; "); |
| 656 sb.add(cookies[i].name); | 656 sb.add(cookies[i].name); |
| 657 sb.add("="); | 657 sb.add("="); |
| 658 sb.add(cookies[i].value); | 658 sb.add(cookies[i].value); |
| 659 } | 659 } |
| 660 headers.add("cookie", sb.toString()); | 660 headers.add(HttpHeaders.COOKIE, sb.toString()); |
| 661 } | 661 } |
| 662 | 662 |
| 663 headers._finalize(); | 663 headers._finalize(); |
| 664 | 664 |
| 665 // Write headers. | 665 // Write headers. |
| 666 headers._write(this); | 666 headers._write(this); |
| 667 writeCRLF(); | 667 writeCRLF(); |
| 668 } | 668 } |
| 669 } | 669 } |
| 670 | 670 |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 | 1656 |
| 1657 | 1657 |
| 1658 class _RedirectInfo implements RedirectInfo { | 1658 class _RedirectInfo implements RedirectInfo { |
| 1659 const _RedirectInfo(int this.statusCode, | 1659 const _RedirectInfo(int this.statusCode, |
| 1660 String this.method, | 1660 String this.method, |
| 1661 Uri this.location); | 1661 Uri this.location); |
| 1662 final int statusCode; | 1662 final int statusCode; |
| 1663 final String method; | 1663 final String method; |
| 1664 final Uri location; | 1664 final Uri location; |
| 1665 } | 1665 } |
| OLD | NEW |