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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 12389050: Remane io_stream_consumer.dart to io_sink and move out all implementation from IOSink to _IOSinkImp… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make _DetachedSocket pass dart-analyzer. Created 7 years, 10 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 | sdk/lib/io/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index ee36808eaea7459082c51a7ad5072106f22020e5..31099ccf03910fac880959c64a9b97e406ab6096 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -318,14 +318,21 @@ class _HttpClientResponse
}
-abstract class _HttpOutboundMessage<T> extends IOSink {
+abstract class _HttpOutboundMessage<T> implements IOSink {
// Used to mark when the body should be written. This is used for HEAD
// requests and in error handling.
bool _ignoreBody = false;
+ bool _headersWritten = false;
+ bool _chunked = false;
+
+ final IOSink _ioSink;
+ final _HttpOutgoing _outgoing;
+
+ final _HttpHeaders headers;
_HttpOutboundMessage(String protocolVersion, _HttpOutgoing outgoing)
- : super(outgoing),
- _outgoing = outgoing,
+ : _outgoing = outgoing,
+ _ioSink = new IOSink(outgoing),
headers = new _HttpHeaders(protocolVersion);
int get contentLength => headers.contentLength;
@@ -345,27 +352,31 @@ abstract class _HttpOutboundMessage<T> extends IOSink {
// Transform when chunked.
stream = stream.transform(new _ChunkedTransformer());
}
- return super.consume(stream).then((_) => this);
+ return _ioSink.consume(stream).then((_) => this);
}
void add(List<int> data) {
_writeHeaders();
if (_ignoreBody || data.length == 0) return;
if (_chunked) {
- _ChunkedTransformer._addChunk(data, super.add);
+ _ChunkedTransformer._addChunk(data, _ioSink.add);
} else {
- super.add(data);
+ _ioSink.add(data);
}
}
- Future addStream(Stream<List<int>> stream) {
+ void addString(String string, [Encoding encoding = Encoding.UTF_8]) {
+ add(_encodeString(string, encoding));
+ }
+
+ Future<T> addStream(Stream<List<int>> stream) {
_writeHeaders();
if (_ignoreBody) return new Future.immediate(this);
if (_chunked) {
// Transform when chunked.
stream = stream.transform(new _ChunkedTransformer(writeEnd: false));
}
- return super.addStream(stream).then((_) => this);
+ return _ioSink.addStream(stream).then((_) => this);
}
void close() {
@@ -377,12 +388,14 @@ abstract class _HttpOutboundMessage<T> extends IOSink {
_writeHeaders();
if (!_ignoreBody) {
if (_chunked) {
- _ChunkedTransformer._addChunk([], super.add);
+ _ChunkedTransformer._addChunk([], _ioSink.add);
}
}
- super.close();
+ _ioSink.close();
}
+ Future<T> get done => _ioSink.done.then((_) => this);
+
void _writeHeaders() {
if (_headersWritten) return;
bool _tmpIgnoreBody = _ignoreBody;
@@ -391,7 +404,7 @@ abstract class _HttpOutboundMessage<T> extends IOSink {
_writeHeader();
_ignoreBody = _tmpIgnoreBody;
if (_ignoreBody) {
- super.close();
+ _ioSink.close();
return;
}
_chunked = headers.chunkedTransferEncoding;
@@ -401,12 +414,6 @@ abstract class _HttpOutboundMessage<T> extends IOSink {
}
void _writeHeader(); // TODO(ajohnsen): Better name.
-
- final _HttpHeaders headers;
-
- final _HttpOutgoing _outgoing;
- bool _headersWritten = false;
- bool _chunked = false;
}
@@ -1485,7 +1492,7 @@ class _HttpConnectionInfo implements HttpConnectionInfo {
}
-class _DetachedSocket implements Socket {
+class _DetachedSocket extends Stream<List<int>> implements Socket {
final Stream<List<int>> _incoming;
final Socket _socket;
@@ -1517,6 +1524,9 @@ class _DetachedSocket implements Socket {
void add(List<int> data) => _socket.add(data);
void close() => _socket.close();
Future<Socket> get done => _socket.done;
+ int get port => _socket.port;
+ String get remoteHost => _socket.remoteHost;
+ int get remotePort => _socket.remotePort;
}
« no previous file with comments | « no previous file | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698