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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/http.dart ('k') | tests/standalone/io/http_connection_info_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _HttpHeaders implements HttpHeaders { 5 class _HttpHeaders implements HttpHeaders {
6 _HttpHeaders() : _headers = new Map<String, List<String>>(); 6 _HttpHeaders() : _headers = new Map<String, List<String>>();
7 7
8 List<String> operator[](String name) { 8 List<String> operator[](String name) {
9 name = name.toLowerCase(); 9 name = name.toLowerCase();
10 return _headers[name]; 10 return _headers[name];
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 700 }
701 } 701 }
702 702
703 void _updateContentLength(int bytes) { 703 void _updateContentLength(int bytes) {
704 if (_bodyBytesWritten + bytes > _contentLength) { 704 if (_bodyBytesWritten + bytes > _contentLength) {
705 throw new HttpException("Writing more than specified content length"); 705 throw new HttpException("Writing more than specified content length");
706 } 706 }
707 _bodyBytesWritten += bytes; 707 _bodyBytesWritten += bytes;
708 } 708 }
709 709
710 HttpConnectionInfo get connectionInfo() => _httpConnection.connectionInfo;
711
710 int _state; 712 int _state;
711 bool _headResponse; 713 bool _headResponse;
712 714
713 _HttpConnectionBase _httpConnection; 715 _HttpConnectionBase _httpConnection;
714 _HttpHeaders _headers; 716 _HttpHeaders _headers;
715 List<Cookie> _cookies; 717 List<Cookie> _cookies;
716 String _protocolVersion = "1.1"; 718 String _protocolVersion = "1.1";
717 719
718 // Length of the content body. If this is set to -1 (default value) 720 // Length of the content body. If this is set to -1 (default value)
719 // when starting to send data chunked transfer encoding will be 721 // when starting to send data chunked transfer encoding will be
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 _socket.onData = null; 1236 _socket.onData = null;
1235 _socket.onClosed = null; 1237 _socket.onClosed = null;
1236 _socket.onError = null; 1238 _socket.onError = null;
1237 _socket.outputStream.onNoPendingWrites = null; 1239 _socket.outputStream.onNoPendingWrites = null;
1238 Socket socket = _socket; 1240 Socket socket = _socket;
1239 _socket = null; 1241 _socket = null;
1240 if (onDetach != null) onDetach(); 1242 if (onDetach != null) onDetach();
1241 return new _DetachedSocket(socket, _httpParser.unparsedData); 1243 return new _DetachedSocket(socket, _httpParser.unparsedData);
1242 } 1244 }
1243 1245
1246 HttpConnectionInfo get connectionInfo() {
1247 if (_socket == null || _closing || _error) return null;
1248 try {
1249 _HttpConnectionInfo info = new _HttpConnectionInfo();
1250 info.remoteHost = _socket.remoteHost;
1251 info.remotePort = _socket.remotePort;
1252 info.localPort = _socket.port;
1253 return info;
1254 } catch (var e) { }
1255 return null;
1256 }
1257
1244 abstract void _onConnectionClosed(e); 1258 abstract void _onConnectionClosed(e);
1245 abstract void _responseDone(); 1259 abstract void _responseDone();
1246 1260
1247 void set _onNoPendingWrites(void callback()) { 1261 void set _onNoPendingWrites(void callback()) {
1248 if (!_error) { 1262 if (!_error) {
1249 _socket.outputStream.onNoPendingWrites = callback; 1263 _socket.outputStream.onNoPendingWrites = callback;
1250 } 1264 }
1251 } 1265 }
1252 1266
1253 int hashCode() => _hashCode; 1267 int hashCode() => _hashCode;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 } 2107 }
2094 2108
2095 Function _onOpen; 2109 Function _onOpen;
2096 Map<String, Queue<_SocketConnection>> _openSockets; 2110 Map<String, Queue<_SocketConnection>> _openSockets;
2097 Set<_SocketConnection> _activeSockets; 2111 Set<_SocketConnection> _activeSockets;
2098 Timer _evictionTimer; 2112 Timer _evictionTimer;
2099 bool _shutdown; // Has this HTTP client been shutdown? 2113 bool _shutdown; // Has this HTTP client been shutdown?
2100 } 2114 }
2101 2115
2102 2116
2117 class _HttpConnectionInfo implements HttpConnectionInfo {
2118 String remoteHost;
2119 int remotePort;
2120 int localPort;
2121 }
2122
2123
2103 class _DetachedSocket implements DetachedSocket { 2124 class _DetachedSocket implements DetachedSocket {
2104 _DetachedSocket(this._socket, this._unparsedData); 2125 _DetachedSocket(this._socket, this._unparsedData);
2105 Socket get socket() => _socket; 2126 Socket get socket() => _socket;
2106 List<int> get unparsedData() => _unparsedData; 2127 List<int> get unparsedData() => _unparsedData;
2107 Socket _socket; 2128 Socket _socket;
2108 List<int> _unparsedData; 2129 List<int> _unparsedData;
2109 } 2130 }
2110 2131
2111 2132
2112 class _RedirectInfo implements RedirectInfo { 2133 class _RedirectInfo implements RedirectInfo {
2113 const _RedirectInfo(int this.statusCode, 2134 const _RedirectInfo(int this.statusCode,
2114 String this.method, 2135 String this.method,
2115 Uri this.location); 2136 Uri this.location);
2116 final int statusCode; 2137 final int statusCode;
2117 final String method; 2138 final String method;
2118 final Uri location; 2139 final Uri location;
2119 } 2140 }
OLDNEW
« 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