Index: runtime/bin/http_impl.dart |
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart |
index 9a3d9df04ae621bf7701a7dff12c689b6ee7c84a..91e528380aabeb5f495a01be8186b2de5e04804e 100644 |
--- a/runtime/bin/http_impl.dart |
+++ b/runtime/bin/http_impl.dart |
@@ -1056,14 +1056,39 @@ class _HttpClient implements HttpClient { |
return _prepareHttpClientConnection(host, port, method, path); |
} |
+ HttpClientConnection openUrl(String method, Uri url) { |
+ if (url.scheme != "http") { |
+ throw new HttpException("Unsupported URL scheme ${url.scheme}"); |
+ } |
+ if (url.userInfo != "") { |
+ throw new HttpException("Unsupported user info in URL"); |
Mads Ager (google)
2012/03/08 08:02:52
Interpolate the userInfo?
Søren Gjesse
2012/03/08 08:30:04
Done.
|
+ } |
+ int port = url.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : url.port; |
+ String path; |
Mads Ager (google)
2012/03/08 08:02:52
After the sanity checks, could you just use url.to
Søren Gjesse
2012/03/08 08:30:04
Unfortunately not, at that will add the prefix "ht
|
+ if (url.query != "") { |
+ if (url.fragment != "") { |
+ path = "${url.path}?${url.query}#${url.fragment}"; |
+ } else { |
+ path = "${url.path}?${url.query}"; |
+ } |
+ } else { |
+ path = url.path; |
+ } |
+ return open(method, url.domain, port, path); |
+ } |
+ |
HttpClientConnection get(String host, int port, String path) { |
return open("GET", host, port, path); |
} |
+ HttpClientConnection getUrl(Uri url) => openUrl("GET", url); |
+ |
HttpClientConnection post(String host, int port, String path) { |
return open("POST", host, port, path); |
} |
+ HttpClientConnection postUrl(Uri url) => openUrl("POST", url); |
+ |
void shutdown() { |
_openSockets.forEach((String key, Queue<_SocketConnection> connections) { |
while (!connections.isEmpty()) { |