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

Unified Diff: runtime/bin/http_impl.dart

Issue 10803033: Add the ability to get info of a Http connection, e.g. host and port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Simplify wrapper function and fix a type. Created 8 years, 5 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/io/http_connection_info_test.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 ef590d78287710c3954d4b63c05ce7799676cc8f..c664c512ca6bce3de537be4395153ad939e7dd1a 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -707,6 +707,8 @@ class _HttpRequestResponseBase {
_bodyBytesWritten += bytes;
}
+ HttpConnectionInfo get connectionInfo() => _httpConnection.connectionInfo;
+
int _state;
bool _headResponse;
@@ -1241,6 +1243,18 @@ class _HttpConnectionBase implements Hashable {
return new _DetachedSocket(socket, _httpParser.unparsedData);
}
+ HttpConnectionInfo get connectionInfo() {
+ if (_socket == null || _closing || _error) return null;
+ try {
+ _HttpConnectionInfo info = new _HttpConnectionInfo();
+ info.remoteHost = _socket.remoteHost;
+ info.remotePort = _socket.remotePort;
+ info.localPort = _socket.port;
+ return info;
+ } catch (var e) { }
+ return null;
+ }
+
abstract void _onConnectionClosed(e);
abstract void _responseDone();
@@ -2100,6 +2114,13 @@ class _HttpClient implements HttpClient {
}
+class _HttpConnectionInfo implements HttpConnectionInfo {
+ String remoteHost;
+ int remotePort;
+ int localPort;
+}
+
+
class _DetachedSocket implements DetachedSocket {
_DetachedSocket(this._socket, this._unparsedData);
Socket get socket() => _socket;
« no previous file with comments | « runtime/bin/http.dart ('k') | tests/standalone/io/http_connection_info_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698