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

Unified Diff: runtime/bin/http_impl.dart

Issue 10262031: Add a web socket client (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
Index: runtime/bin/http_impl.dart
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
index e8e5ff14bf0c59d36a626089939a763f320d03c0..7de85a8149b4fad112c70c14ee0294276ddf849f 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -467,7 +467,7 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
return _outputStream;
}
- Socket detachSocket() {
+ DetachedSocket detachSocket() {
if (_state >= DONE) throw new HttpException("Response closed");
// Ensure that headers are written.
if (_state == START) {
@@ -602,7 +602,7 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
// whether the content length is known.
if (_contentLength > 0) {
_headers.set("Content-Length", _contentLength.toString());
- } else {
+ } else if (_contentLength < 0) {
Mads Ager (google) 2012/05/02 08:18:17 An nothing needs to be done here fore _contentLeng
Søren Gjesse 2012/05/02 10:22:45 Yes - this was a bug. The spec says: "The presenc
_headers.set("Transfer-Encoding", "chunked");
}
@@ -745,8 +745,10 @@ class _HttpConnectionBase implements Hashable {
int parsed = _httpParser.writeList(buffer, 0, bytesRead);
if (!_httpParser.upgrade) {
if (parsed != bytesRead) {
- // TODO(sgjesse): Error handling.
- _close();
+ if (_socket != null) {
+ // TODO(sgjesse): Error handling.
+ _close();
+ }
}
}
}
@@ -766,7 +768,7 @@ class _HttpConnectionBase implements Hashable {
_onConnectionClosed(e);
}
- Socket _detachSocket() {
+ DetachedSocket _detachSocket() {
_socket.onData = null;
// TODO(sgjesse): Handle getting the write handler when using output stream.
Mads Ager (google) 2012/05/02 08:18:17 Let's file a bug report on this to keep track?
Søren Gjesse 2012/05/02 10:22:45 Fixed by setting _socket.outputStream.onNoPendingW
//_socket.onWrite = null;
@@ -774,8 +776,8 @@ class _HttpConnectionBase implements Hashable {
_socket.onError = null;
Socket socket = _socket;
_socket = null;
- if (onDetach) onDetach();
- return socket;
+ if (onDetach != null) onDetach();
+ return new DetachedSocket(socket, _httpParser.unparsedData);
}
abstract void _onConnectionClosed(e);
@@ -1231,6 +1233,11 @@ class _HttpClientConnection
return _request;
}
+ DetachedSocket detachSocket() {
+ // TODO(sgjesse): Needs some state checks.
Mads Ager (google) 2012/05/02 08:18:17 Either add the checks or file a bug to keep track?
Søren Gjesse 2012/05/02 10:22:45 Removed the TODO - not sure which state checks I w
+ return _detachSocket();
+ }
+
void _onConnectionClosed(e) {
// Socket is closed either due to an error or due to normal socket close.
if (e != null) {

Powered by Google App Engine
This is Rietveld 408576698