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

Unified Diff: runtime/bin/http_impl.dart

Issue 11035030: Refactor HttpClient internals to use Uri class for passing connection information (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | 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 9f3106a5b72338887d967505de0619a13a335079..79290466a8f4dd4e15d175439949f6c0539bc8e1 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -1958,19 +1958,20 @@ class _HttpClient implements HttpClient {
HttpClientConnection open(
String method, String host, int port, String path) {
- return _open(method, host, port, path);
+ // TODO(sgjesse): The path set here can contain both query and
+ // fragment. They should be cracked and set correctly.
+ return _open(method, new Uri.fromComponents(
+ scheme: "http", domain: host, port: port, path: path));
}
HttpClientConnection _open(String method,
- String host,
- int port,
- String path,
+ Uri uri,
[_HttpClientConnection connection]) {
if (_shutdown) throw new HttpException("HttpClient shutdown");
- if (method == null || host == null || port == null || path == null) {
+ if (method == null || uri.domain.isEmpty() == null) {
throw new ArgumentError(null);
}
- return _prepareHttpClientConnection(host, port, method, path, connection);
+ return _prepareHttpClientConnection(method, uri, connection);
}
HttpClientConnection openUrl(String method, Uri url) {
@@ -1986,28 +1987,17 @@ class _HttpClient implements HttpClient {
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, connection);
+ return _open(method, url, connection);
}
HttpClientConnection get(String host, int port, String path) {
- return _open("GET", host, port, 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);
+ return open("POST", host, port, path);
}
HttpClientConnection postUrl(Uri url) => _openUrl("POST", url);
@@ -2036,18 +2026,26 @@ class _HttpClient implements HttpClient {
}
HttpClientConnection _prepareHttpClientConnection(
- String host,
- int port,
String method,
- String path,
+ Uri url,
[_HttpClientConnection connection]) {
void _connectionOpened(_SocketConnection socketConn,
_HttpClientConnection connection) {
connection._connectionEstablished(socketConn);
+ 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;
+ }
HttpClientRequest request = connection.open(method, path);
- request.headers.host = host;
- request.headers.port = port;
+ request.headers.host = socketConn._host;
Anders Johnsen 2012/10/04 13:15:29 Why not url.domain/url.port?
Søren Gjesse 2012/10/04 14:11:48 That was wrong fixed.
+ request.headers.port = socketConn._port;
if (connection._onRequest != null) {
connection._onRequest(request);
} else {
@@ -2063,6 +2061,8 @@ class _HttpClient implements HttpClient {
// If there are active connections for this key get the first one
// otherwise create a new one.
+ String host = url.domain;
+ int port = url.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : url.port;
String key = _connectionKey(host, port);
Queue socketConnections = _openSockets[key];
if (socketConnections == null || socketConnections.isEmpty()) {
@@ -2158,6 +2158,7 @@ class _HttpClient implements HttpClient {
Map<String, Queue<_SocketConnection>> _openSockets;
Set<_SocketConnection> _activeSockets;
Timer _evictionTimer;
+ Function _findProxy;
Anders Johnsen 2012/10/04 13:15:29 I guess this is an (too) early start on proxy? :)
bool _shutdown; // Has this HTTP client been shutdown?
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698