Version 1.3.4

svn merge -c 35071 https://dart.googlecode.com/svn/branches/bleeding_edge 1.3

R=ajohnsen@google.com

Review URL: https://codereview.chromium.org//250453004

git-svn-id: http://dart.googlecode.com/svn/branches/1.3@35363 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index b46bf5e..f31975e 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -1068,7 +1068,15 @@
         .then((socket) => new _RawServerSocket(socket));
   }
 
-  _RawServerSocket(this._socket) {
+  _RawServerSocket(this._socket);
+
+  StreamSubscription<RawSocket> listen(void onData(RawSocket event),
+                                       {Function onError,
+                                        void onDone(),
+                                        bool cancelOnError}) {
+    if (_controller != null) {
+      throw new StateError("Stream was already listened to");
+    }
     var zone = Zone.current;
     _controller = new StreamController(sync: true,
         onListen: _onSubscriptionStateChange,
@@ -1087,14 +1095,7 @@
         _controller.addError(e);
         _controller.close();
       }),
-      destroyed: _controller.close
-    );
-  }
-
-  StreamSubscription<RawSocket> listen(void onData(RawSocket event),
-                                       {Function onError,
-                                        void onDone(),
-                                        bool cancelOnError}) {
+      destroyed: _controller.close);
     return _controller.stream.listen(
         onData,
         onError: onError,
diff --git a/tests/standalone/io/http_server_test.dart b/tests/standalone/io/http_server_test.dart
index 4eb8df5..f664501 100644
--- a/tests/standalone/io/http_server_test.dart
+++ b/tests/standalone/io/http_server_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import "dart:async";
+import "dart:typed_data";
 import "dart:io";
 
 import "package:async_helper/async_helper.dart";
@@ -110,8 +111,34 @@
 }
 
 
+void testHttpServerClientClose() {
+  HttpServer.bind("127.0.0.1", 0).then((server) {
+    runZoned(() {
+      server.listen((request) {
+        request.response.bufferOutput = false;
+        request.response.add(new Uint8List(64 * 1024));
+        new Timer(const Duration(milliseconds: 100), () {
+          request.response.close().then((_) {
+            server.close();
+          });
+        });
+      });
+    }, onError: (e, s) {
+      Expect.fail("Unexpected error: $e(${e.hashCode})\n$s");
+    });
+    var client = new HttpClient();
+    client.get("127.0.0.1", server.port, "/")
+        .then((request) => request.close())
+        .then((response) {
+          response.listen((_) {}).cancel();
+        });
+  });
+}
+
+
 void main() {
   testListenOn();
   testHttpServerZone();
   testHttpServerZoneError();
+  testHttpServerClientClose();
 }
diff --git a/tools/VERSION b/tools/VERSION
index bc7988f..3316975 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
 CHANNEL stable
 MAJOR 1
 MINOR 3
-PATCH 3
+PATCH 4
 PRERELEASE 0
 PRERELEASE_PATCH 0