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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | tests/corelib/uri_path_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 0a16be90a452f51db8d237f26f90b4a22a9b8cd2..15d7ee84d5800ccbd0dd4ee6ac431ee0c33e0c04 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1485,6 +1485,7 @@ class _HttpClient implements HttpClient {
Future<HttpClientRequest> _openUrlFromRequest(String method,
Uri uri,
_HttpClientRequest previous) {
+ var u = uri;
// If the new URI is relative (to either '/' or some sub-path),
// construct a full URI from the previous one.
// See http://tools.ietf.org/html/rfc3986#section-4.2
@@ -1497,17 +1498,24 @@ class _HttpClient implements HttpClient {
query: uri.query,
fragment: uri.fragment);
}
+
+ var scheme;
+ var host;
+ var port;
+ var path;
if (uri.host.isEmpty) {
- replaceComponents(host: previous.uri.host, port: previous.uri.port);
+ host = previous.uri.host;
+ port = previous.uri.port;
}
if (uri.scheme.isEmpty) {
- replaceComponents(scheme: previous.uri.scheme);
+ scheme = previous.uri.scheme;
}
- if (!uri.path.startsWith('/') && previous.uri.path.startsWith('/')) {
+ if (!uri.path.startsWith('/')) {
var absolute = new Path.raw(previous.uri.path).directoryPath;
- absolute = absolute.join(new Path.raw(uri.path));
- replaceComponents(path: absolute.canonicalize().toString());
+ absolute = absolute.join(new Path.raw(u.path));
+ path = absolute.canonicalize().toString();
}
+ replaceComponents(scheme: scheme, host: host, port: port, path: path);
return openUrl(method, uri).then((_HttpClientRequest request) {
// Only follow redirects if initial request did.
request.followRedirects = previous.followRedirects;
« 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