By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,192 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,192 IT Pros & Developers. It's quick & easy.

Is it possible to retrieve http response status?

P: n/a
I am using Selenium, a javascript framework for automated testing of
web application. The problem occurs when there is a server side HTTP
redirect. Selenium would detect that a new page is loaded, proceed to
the next command which then fail because the browser is carrying out
the redirect. So, is it possible to use javascript on the browser
side (Firefox 2) to get the http response status code?
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Khai Doan wrote:
I am using Selenium, a javascript framework for automated testing of
web application. The problem occurs when there is a server side HTTP
redirect. Selenium would detect that a new page is loaded, proceed to
the next command which then fail because the browser is carrying out
the redirect. So, is it possible to use javascript on the browser
side (Firefox 2) to get the http response status code?
If you use XMLHttpRequest to make an HTTP request then you can read out
the status and statusText properties:
http://developer.mozilla.org/en/docs/XMLHttpRequest

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2

P: n/a
Martin Honnen wrote:
Khai Doan wrote:
>I am using Selenium, a javascript framework for automated testing of
web application. The problem occurs when there is a server side HTTP
redirect. Selenium would detect that a new page is loaded, proceed to
the next command which then fail because the browser is carrying out
the redirect. So, is it possible to use javascript on the browser
side (Firefox 2) to get the http response status code?

If you use XMLHttpRequest to make an HTTP request then you can read out
the status and statusText properties:
http://developer.mozilla.org/en/docs/XMLHttpRequest
XHR handles server-side redirects transparently, so it cannot be used to
detect whether a redirect took place. The value of the status property is
either a success status code (2xx) or an error status code (4xx or 5xx)[1],
never that of a redirect (3xx).
PointedEars
___________
[1] It may be also 0 when using XHR to access the local filesystem directly.
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.