views:

212

answers:

1

A web-server is returning a status code and description in response to a request by an XmlHttp component. The actual status response from the server begins with:

HTTP/1.1 400 Not a valid http POST request

which i can see in though a Fiddler trace:

alt text

But when i ask the xmlHttp request for the status and statusText, it shows me the "standard" description for the status text, rather than the actual status text:

xmlHttp.status: 200
xmlHttp.statusText: "Bad Request"

which i can see in in the development IDE:

alt text

i've poked around all the other properties of IXMLHttpRequest, and i can't find any that contain the response's actual status text. It's not even in any of the response headers:

Server: ASP.NET Development Server/8.0.0.0
Date: Thu, 28 Jan 2010 21:03:16 GMT
X-AspNet-Version: 2.0.50727
X-LSI-Proxy-Identificaton: {65B76AB2-8A28-4A2B-B282-7E1FDC9DBCA1}
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/xml; charset=utf-8
Content-Length: 4652
Connection: Close

Internet Explorer, Chrome, and FireFox manage to read the actual status text:

alt text

How can i get the actual statusText from a Microsoft xmlHttp object?

+1  A: 

Unfortunately code 400 is defined as Bad Request as part of the HTTP/1.1 RFC and XMLHTTP (well more likely URLMON or WinHTTP) is just transforming the number and ignoring the passed status text. As the status line is part of the protocol and not a response header then it makes sense it isn't defined in the list of response headers.

However I would contend that the browsers are only showing the status text "correctly" because they are displaying the custom HTML page which got sent along with it which has that text as the TITLE in the HEAD element.

tyranid
Looks like you are right on both counts. (1) xmlhttp is using the default status descriptions, rather than the returned ones, and (2) the title contains the html title, not the http status code and statusText.
Ian Boyd