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

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

Issue 16470004: Add leading slash to URI path when required. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | tests/corelib/uri_path_test.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 class _HttpIncoming extends Stream<List<int>> { 7 class _HttpIncoming extends Stream<List<int>> {
8 final int _transferLength; 8 final int _transferLength;
9 final Completer _dataCompleter = new Completer(); 9 final Completer _dataCompleter = new Completer();
10 Stream<List<int>> _stream; 10 Stream<List<int>> _stream;
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 return _getConnection(uri.host, port, proxyConf, isSecure) 1478 return _getConnection(uri.host, port, proxyConf, isSecure)
1479 .then(send); 1479 .then(send);
1480 } 1480 }
1481 return send(info); 1481 return send(info);
1482 }); 1482 });
1483 } 1483 }
1484 1484
1485 Future<HttpClientRequest> _openUrlFromRequest(String method, 1485 Future<HttpClientRequest> _openUrlFromRequest(String method,
1486 Uri uri, 1486 Uri uri,
1487 _HttpClientRequest previous) { 1487 _HttpClientRequest previous) {
1488 var u = uri;
1488 // If the new URI is relative (to either '/' or some sub-path), 1489 // If the new URI is relative (to either '/' or some sub-path),
1489 // construct a full URI from the previous one. 1490 // construct a full URI from the previous one.
1490 // See http://tools.ietf.org/html/rfc3986#section-4.2 1491 // See http://tools.ietf.org/html/rfc3986#section-4.2
1491 replaceComponents({scheme, host, port, path}) { 1492 replaceComponents({scheme, host, port, path}) {
1492 uri = new Uri( 1493 uri = new Uri(
1493 scheme: scheme != null ? scheme : uri.scheme, 1494 scheme: scheme != null ? scheme : uri.scheme,
1494 host: host != null ? host : uri.host, 1495 host: host != null ? host : uri.host,
1495 port: port != null ? port : uri.port, 1496 port: port != null ? port : uri.port,
1496 path: path != null ? path : uri.path, 1497 path: path != null ? path : uri.path,
1497 query: uri.query, 1498 query: uri.query,
1498 fragment: uri.fragment); 1499 fragment: uri.fragment);
1499 } 1500 }
1501
1502 var scheme;
1503 var host;
1504 var port;
1505 var path;
1500 if (uri.host.isEmpty) { 1506 if (uri.host.isEmpty) {
1501 replaceComponents(host: previous.uri.host, port: previous.uri.port); 1507 host = previous.uri.host;
1508 port = previous.uri.port;
1502 } 1509 }
1503 if (uri.scheme.isEmpty) { 1510 if (uri.scheme.isEmpty) {
1504 replaceComponents(scheme: previous.uri.scheme); 1511 scheme = previous.uri.scheme;
1505 } 1512 }
1506 if (!uri.path.startsWith('/') && previous.uri.path.startsWith('/')) { 1513 if (!uri.path.startsWith('/')) {
1507 var absolute = new Path.raw(previous.uri.path).directoryPath; 1514 var absolute = new Path.raw(previous.uri.path).directoryPath;
1508 absolute = absolute.join(new Path.raw(uri.path)); 1515 absolute = absolute.join(new Path.raw(u.path));
1509 replaceComponents(path: absolute.canonicalize().toString()); 1516 path = absolute.canonicalize().toString();
1510 } 1517 }
1518 replaceComponents(scheme: scheme, host: host, port: port, path: path);
1511 return openUrl(method, uri).then((_HttpClientRequest request) { 1519 return openUrl(method, uri).then((_HttpClientRequest request) {
1512 // Only follow redirects if initial request did. 1520 // Only follow redirects if initial request did.
1513 request.followRedirects = previous.followRedirects; 1521 request.followRedirects = previous.followRedirects;
1514 // Allow same number of redirects. 1522 // Allow same number of redirects.
1515 request.maxRedirects = previous.maxRedirects; 1523 request.maxRedirects = previous.maxRedirects;
1516 // Copy headers. 1524 // Copy headers.
1517 for (var header in previous.headers._headers.keys) { 1525 for (var header in previous.headers._headers.keys) {
1518 if (request.headers[header] == null) { 1526 if (request.headers[header] == null) {
1519 request.headers.set(header, previous.headers[header]); 1527 request.headers.set(header, previous.headers[header]);
1520 } 1528 }
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 2337
2330 2338
2331 class _RedirectInfo implements RedirectInfo { 2339 class _RedirectInfo implements RedirectInfo {
2332 const _RedirectInfo(int this.statusCode, 2340 const _RedirectInfo(int this.statusCode,
2333 String this.method, 2341 String this.method,
2334 Uri this.location); 2342 Uri this.location);
2335 final int statusCode; 2343 final int statusCode;
2336 final String method; 2344 final String method;
2337 final Uri location; 2345 final Uri location;
2338 } 2346 }
OLDNEW
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | tests/corelib/uri_path_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698