<?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>10638</bug_id>
          
          <creation_ts>2006-08-30 05:34:48 -0700</creation_ts>
          <short_desc>XMLHttpRequest on Windows doesn&apos;t give correct status</short_desc>
          <delta_ts>2007-07-02 05:01:31 -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>Page Loading</component>
          <version>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Karthik Kumar">karthikkumar</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>daniel</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>54230</commentid>
    <comment_count>0</comment_count>
    <who name="Karthik Kumar">karthikkumar</who>
    <bug_when>2006-08-30 05:34:48 -0700</bug_when>
    <thetext>When an XMLHTTPRequest object&apos;s readyState is 4, it doesn&apos;t give me the correct server status (request.status element).. It is null instead of a value like 200, 301 or something. 

sample code to test: (tested in Firefox/Opera/IE)

     function processResponse(httprequest){
 	 var response=null;
  	 if(httprequest==null) return response;
	 if(httprequest.readyState&gt;0&amp;&amp;httprequest.readyState&lt;4){
		showAjax();
	 }
	 else if(httprequest.readyState==4) {
   		hideAjax();
		if(httprequest.status == 200) {
			var responsewrapper=getJSONObject(httprequest.responseText);
			authenticated=false;
			if(responsewrapper!=null) 
				response=responsewrapper.response;
			if(response!=null) {
					authenticateResponse(response);
					errorResponse(response);	
					return response;
			} 	
			showStatus(STATUS_ERROR, &quot;JSON Error: Couldn&apos;t read response.&quot;);
		}
		else 
			showStatus(STATUS_ERROR, &quot;AJAX Error: Server HTTP status: &quot;+httprequest.status); //Note this: XXXX
	}
	return response;
    } 


//XXXX:	throws: AJAX Error: Server HTTP tatus: [undefined] in Swift

the callback to XMLHTTPRequest is: 

...
var httprequest=makeHTTPRequest(); //returns object successful
httprequest.onreadystatechange=function (){ processResponse(httprequest); }

...

httprequest.open(&quot;GET&quot;, url, true); //Last parameter is true.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54723</commentid>
    <comment_count>1</comment_count>
    <who name="Daniel Kinzler">daniel</who>
    <bug_when>2006-09-03 13:19:27 -0700</bug_when>
    <thetext>I can confirm that this appears to be a problem for some people (I don&apos;t have Safari around to check for myself, so the below is second hand). This bug hits safari users when using an extension i recently contributed to wikipedia - see &lt;http://bugzilla.wikimedia.org/show_bug.cgi?id=7219&gt;. Note that I will try to write a workaround, so it may not be possible to reproduce the problem on wikipedia.

The Problem: apperently, status, statusText, responseText and maybe other fields are null if the response from the server was empty. But empty content is valid in HTTP - so responseText should be an empty string, and status and statusText should represent what the server actually sent (200 OK, hopefully).

I have seen reports of the same problem showing up if the server responds with &quot;304 Not Modified&quot; (see &lt;http://www.bitterpill.org/bp/2005-06/safari-xmlhttprequest-undefine.html&gt;) - please check this while you are at it. As per the w3c draft, 304s should be handeled transparently by XMLHttpRequest (as 200 OK), unless If-Modified-Since was sent explicitely using setRequestHeader, in which case the actual response (with code 304) should be passed on the to JS code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54734</commentid>
    <comment_count>2</comment_count>
    <who name="Daniel Kinzler">daniel</who>
    <bug_when>2006-09-03 14:32:48 -0700</bug_when>
    <thetext>I have been told to file the above comment as a separate issue, see &lt;http://bugzilla.opendarwin.org/show_bug.cgi?id=10716&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5730</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-07-02 05:01:31 -0700</bug_when>
    <thetext>I think this should be fixed in Safari 3 beta for Windows.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>