简体   繁体   中英

XmlHttp: How to get the actual statusText from an msxml.xmlhttp object?

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:

替代文字

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:

替代文字

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:

替代文字

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM