Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Is it possible to retrieve http response status?

Reply
Thread Tools

Is it possible to retrieve http response status?

 
 
Khai Doan
Guest
Posts: n/a
 
      05-22-2008
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?
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      05-22-2008
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/
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-22-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve the HTTP response contents like header, posts, HTML,etc.? Amit Bobade Ruby 1 05-27-2011 08:38 PM
Can I change the response URL to http://server/page.XLS instead of http://server/page.ASPX ? guillermojco@gmail.com ASP .Net 3 04-26-2007 04:49 AM
return HttpStatusCode.ServiceUnavailable in the context.context.Response.StatusCode (Http response code 503) Flip Rayner ASP .Net 1 01-23-2007 06:35 AM
how can i simulate my pc as http server by writing java code to send the http response by socketstream to some pc in the internet?! mike Java 5 09-21-2004 02:04 PM
How to Remove Http header from http response Vivek Mehta XML 3 08-12-2004 02:02 AM



Advertisments