<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -81,7 +81,7 @@ end
 if $0 == __FILE__
   require DIR + '/../lib/ebb'
   Ebb::start_server(SimpleApp.new, 
-                     :port =&gt; 4001,
+                     :port =&gt; 4001
 #                     :ssl_cert =&gt; &quot;/home/ryan/projects/ebb/benchmark/ca-cert.pem&quot;,
 #                     :ssl_key =&gt; &quot;/home/ryan/projects/ebb/benchmark/ca-key.pem&quot;
                     )</diff>
      <filename>benchmark/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -103,6 +103,7 @@ module Ebb
     end
 
     def on_open
+      @being_written = nil
       @requests = []
       @@responses[self] = []
     end
@@ -158,7 +159,6 @@ module Ebb
       @head = &quot;HTTP/1.1 #{status} #{HTTP_STATUS_CODES[status.to_i]}\r\n&quot;
       headers.each { |field, value| @head &lt;&lt; &quot;#{field}: #{value}\r\n&quot; }
       @head &lt;&lt; &quot;\r\n&quot;
-      @output &lt;&lt; @head
 
       # XXX i would prefer to do
       # @chunked = true unless body.respond_to?(:length)
@@ -170,7 +170,6 @@ module Ebb
       
       body.each do |chunk| 
         write(chunk) 
-        @connection.write
       end
 
       body.on_error { close } if body.respond_to?(:on_error)
@@ -191,15 +190,18 @@ module Ebb
 
     def finish
       @finished = true 
-      if @chunked
-        write(&quot;&quot;) 
-        @connection.write
-      end
+      write(&quot;&quot;) if @chunked
     end
     
     def write(chunk)
       encoded = @chunked ? &quot;#{chunk.length.to_s(16)}\r\n#{chunk}\r\n&quot; : chunk
-      @output &lt;&lt; encoded
+      if @head.nil?
+        @output &lt;&lt; encoded
+      else
+        @output &lt;&lt; @head + encoded
+        @head = nil
+      end
+      @connection.write
     end
 
     HTTP_STATUS_CODES = {</diff>
      <filename>lib/ebb.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ce063c507279157fe641a473ea02910bed3d07cd</id>
    </parent>
  </parents>
  <author>
    <name>Ryan</name>
    <email>ry@tinyclouds.org</email>
  </author>
  <url>http://github.com/ry/ebb/commit/61f4cc1356f7fde248a6b966d31be25bf8a97a22</url>
  <id>61f4cc1356f7fde248a6b966d31be25bf8a97a22</id>
  <committed-date>2008-08-19T01:55:38-07:00</committed-date>
  <authored-date>2008-08-19T01:55:38-07:00</authored-date>
  <message>make sure the first chunk is written with the header</message>
  <tree>f414af373b60608c771aa864cd4572f06a156de1</tree>
  <committer>
    <name>Ryan</name>
    <email>ry@tinyclouds.org</email>
  </committer>
</commit>
