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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 321543003: New, more validating, parser for URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more test. Created 6 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/co19/co19-co19.status » ('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 f9fedc3410bf898fec9521989910eeef3ea6c366..3e1a059dd6cced6087e766aae6a8e033597f10a3 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1674,10 +1674,34 @@ class _HttpClient implements HttpClient {
String host,
int port,
String path) {
- // TODO(sgjesse): The path set here can contain both query and
- // fragment. They should be cracked and set correctly.
+ const int _NUMBER_SIGN = 0x23;
+ const int _QUESTION = 0x3F;
+ String pathOnly = path;
+ String query;
+ String fragment;
+ // TODO(lrn): Consider dropping the fragment from the Uri.
+ for (int i = 0; i < path.length; i++) {
+ int char = path.codeUnitAt(i);
+ if (char == _NUMBER_SIGN) {
+ pathOnly = path.substring(0, i);
+ fragment = path.substring(i + 1);
+ break;
+ }
+ if (char == _QUESTION) {
+ pathOnly = path.substring(0, i);
+ int queryEnd = path.length;
+ int fragmentStart = path.indexOf("#", i + 1);
+ if (fragmentStart >= 0) {
+ queryEnd = fragmentStart;
+ fragment = path.substring(fragmentStart + 1);
+ }
+ query = path.substring(i + 1, queryEnd);
+ break;
+ }
+ }
return _openUrl(method, new Uri(
- scheme: "http", host: host, port: port, path: path));
+ scheme: "http", host: host, port: port, path: pathOnly,
+ query: query, fragment: fragment));
}
Future<HttpClientRequest> openUrl(String method, Uri url) {
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698