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

Unified Diff: runtime/bin/http_impl.dart

Issue 9625008: Add support for using an URL for establishing HTTP connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed rewiev comments from @ager Created 8 years, 9 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 | « runtime/bin/http.dart ('k') | tests/standalone/src/io/HttpClientTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/http_impl.dart
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
index 9a3d9df04ae621bf7701a7dff12c689b6ee7c84a..38da6eb670225df4f7a909b00faede43647c3f13 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 ${url.userInfo}");
+ }
+ int port = url.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : url.port;
+ String path;
+ 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()) {
« no previous file with comments | « runtime/bin/http.dart ('k') | tests/standalone/src/io/HttpClientTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698