<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -99,7 +99,8 @@ package org.httpclient {
       _closed = true;
       Log.debug(&quot;Called close&quot;);
       _timer.stop();
-      if (_socket) {
+      // Need to check if connected (otherwise closing on unconnected socket throws error)
+      if (_socket &amp;&amp; _socket.connected) {
         _socket.close();
         _socket = null;
       }</diff>
      <filename>src/org/httpclient/HttpSocket.as</filename>
    </modified>
    <modified>
      <diff>@@ -93,6 +93,9 @@ package org.httpclient.io {
               _buffer.truncate();
               _responseHeader = null;
               _isPayloadDone = false;
+            } else if (_responseHeader.code == &quot;204&quot;) {
+              // A 204 is a successful response with No Content
+              _hasResponseBody = false;
             } else {                      
               // Pass any extra as payload
               var payload:ByteArray = _buffer.readAvailable();
@@ -114,9 +117,8 @@ package org.httpclient.io {
       }
       
       // Check if complete
-      Log.debug(&quot;Payload done? &quot; + _isPayloadDone);
-      if (!_hasResponseBody) _onResponseComplete(_responseHeader);
-      else if (_isPayloadDone) _onResponseComplete(_responseHeader);
+      Log.debug(&quot;Has response body? &quot; + _hasResponseBody + &quot;; Payload done? &quot; + _isPayloadDone);
+      if (!_hasResponseBody || _isPayloadDone) _onResponseComplete(_responseHeader);
     }
     
     /**</diff>
      <filename>src/org/httpclient/io/HttpResponseBuffer.as</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@
  				var ts:TestSuite = new TestSuite();
  				
  				// Toggle this for suite vs single test
- 				var singleTest:Boolean = true;
+ 				var singleTest:Boolean = false;
  				
  				if (!singleTest) {
       	  ts.addTest(new S3Tests());</diff>
      <filename>test/Test.mxml</filename>
    </modified>
    <modified>
      <diff>@@ -98,15 +98,19 @@ package httpclient.http {
       client.get(uri);
       client.cancel();
       // TODO(gabe): Assert canceled
+      
+      client.listener.onClose = addAsync(function(event:Event):void {
+        Log.debug(&quot;On Close&quot;);
+      }, 20 * 1000);
     }
     
     public function testClose():void {
       var client:HttpClient = new HttpClient();
       var uri:URI = new URI(&quot;http://www.amazon.com/&quot;);
       
-      client.listener.onClose = function(event:Event):void {
+      client.listener.onClose = addAsync(function(event:Event):void {
         Log.debug(&quot;On Close&quot;);
-      };
+      }, 5 * 1000);
       
       client.listener.onComplete = function(event:Event):void {
         Log.debug(&quot;On Complete&quot;);
@@ -127,7 +131,7 @@ package httpclient.http {
         if (failListener) fail(&quot;Should be canceled&quot;);
       };
       
-      var uri:URI = new URI(&quot;http://www.amazon.com/&quot;);
+      var uri:URI = new URI(&quot;http://www.google.com/&quot;);
       client.get(uri);
       
       failListener = true;
@@ -141,11 +145,11 @@ package httpclient.http {
      
       client1.listener.onComplete = addAsync(function(event:Event):void {
         Log.debug(&quot;On Complete #1&quot;);
-      }, 5 * 1000); 
+      }, 10 * 1000); 
       
       client2.listener.onComplete = addAsync(function(event:Event):void {
         Log.debug(&quot;On Complete #2&quot;);
-      }, 5 * 1000);
+      }, 10 * 1000);
       
       client1.get(new URI(&quot;http://www.google.com/&quot;));
       client2.get(new URI(&quot;http://www.yahoo.com/&quot;));</diff>
      <filename>test/httpclient/http/GetTest.as</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e704570ec827e07cc86c439b5de408a9117bce48</id>
    </parent>
  </parents>
  <author>
    <name>Gabriel Handford</name>
    <email>gabrielh@gmail.com</email>
  </author>
  <url>http://github.com/gabriel/as3httpclient/commit/c5db3ebe95c6824c1128b0c645385848064c69da</url>
  <id>c5db3ebe95c6824c1128b0c645385848064c69da</id>
  <committed-date>2009-03-05T00:09:25-08:00</committed-date>
  <authored-date>2009-03-05T00:09:25-08:00</authored-date>
  <message>Fixes for socket close and 204</message>
  <tree>7f458db3f1099db299fe25fafba5427ad94e86ec</tree>
  <committer>
    <name>Gabriel Handford</name>
    <email>gabrielh@gmail.com</email>
  </committer>
</commit>
