<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>14431</bug_id>
          
          <creation_ts>2007-06-27 08:01:11 -0700</creation_ts>
          <short_desc>XMLHttpRequest readyState 3 &amp; responseText buffer issues</short_desc>
          <delta_ts>2007-08-28 12:21:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>XML</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.synchroedit.com/pt/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kalle Alm">kalle.alm</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>ChristopherA</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>kalle.alm</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>6088</commentid>
    <comment_count>0</comment_count>
    <who name="Kalle Alm">kalle.alm</who>
    <bug_when>2007-06-27 08:01:11 -0700</bug_when>
    <thetext>Safari 3 does not seem to handle the updating of the responseText buffer during readyState 3 (interactive/loading) of XMLHttpRequests appropriately. The expected behavior is that whenever the server sends/flushes output to the client (browser), the client sets readyState to 3 (if not already), updates the responseText buffer, and triggers a readystatechange. 

Safari seems to only set readyState to 3 once (when loading begins and responseText is an empty string) and then nothing until the loading finishes (readyState -&gt; 4). During tests, we discovered that by &quot;priming&quot; the connection as described by M. Stachowiak below, Safari for Mac OS X seemed to get it some times, but not all. By increasing the &quot;garbage&quot; from 256 to 512 bytes, this solution might work all the time, but this solution isn&apos;t exactly ideal. 

In email discussion, Geoffry Garen confirmed that Safari 3 does indeed issue a ready state change of 3 every time it receives data, and that responseText IS updated every time, which indicates the above behavior is a bug.

We have additionally tried two workarounds, as proposed by Maciej Stachowiak, namely:
1) &quot;prime&quot; the connection with 256 bytes sent before any of the real data.
2) Use a MIME type that won&apos;t be subject to sniffing (I think &quot;application/xml&quot; as opposed to &quot;text/xml&quot; may fit the bill). 

From our tests, it would appear that neither of the above tests seem to do the trick on our example code. 

Demo URLs:
- http://www.synchroedit.com/pt/ (perl test -- clean)
- http://www.synchroedit.com/pf1/ (perl fixes 1+2 above)
- http://www.synchroedit.com/pf2/ (perl fix 2 only)

Source code URLs:
- http://www.synchroedit.com/pt/perl-test.tar.gz
- http://www.synchroedit.com/pf1/perl-fix-1.tar.gz
- http://www.synchroedit.com/pf2/perl-fix-2.tar.gz</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6086</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-06-27 09:31:49 -0700</bug_when>
    <thetext>Since the network layer is outside WebKit (and is not open-source), you may want to also file a bug at &lt;http://bugreport.apple.com&gt; (free registration required). Please post the resulting &quot;Radar&quot; number here.

Once we get a method to disable buffering, we&apos;ll need to use it for XMLHttpRequests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6079</commentid>
    <comment_count>2</comment_count>
    <who name="Kalle Alm">kalle.alm</who>
    <bug_when>2007-06-27 10:13:00 -0700</bug_when>
    <thetext>Submitted report at Apple as well. Problem ID is 5298296.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6076</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-06-27 11:24:04 -0700</bug_when>
    <thetext>Thank you!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5713</commentid>
    <comment_count>4</comment_count>
    <who name="Kalle Alm">kalle.alm</who>
    <bug_when>2007-07-02 13:12:42 -0700</bug_when>
    <thetext>This test WORKS FINE in the iPhone version of Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1333</commentid>
    <comment_count>5</comment_count>
    <who name="Anders Carlsson">andersca</who>
    <bug_when>2007-08-28 12:21:50 -0700</bug_when>
    <thetext>Committed revision 25274.

However, this also depends on changes to lower-level frameworks so it won&apos;t work until newer versions of those have been released.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>