| Milamber³ 2005-09-06, 7:28 pm |
| HI all,
I ahve posted aout this problem before and can't seem to find the solution
myself. I do have some more information that I think might help anyone
trying to help me. Here goes.
I am trying to implement an extension which uses XmlHttpRequest to send a
request to a server and will someimtes get a 302 redirect back. When this
happens I want to be able to extract the new location and some extra info
from the header with the 302 and make the browser navigate to the new
location. The reason for this is that the redirect will almost always be to
a large file and I want firefox to take care of all the file saving bits and
pieces.
SO.
I first used the code in the test page here:
http://www.mozilla.org/xmlextras/get.xhtml to see if it would work and sure
enough it does.
When it gets a 302 the getAllResponseHeaders() box contains the headers
and the repsonseText/responseXML is empty.
When I try and implement this as a plugin the request seems to automatically
follow the redirect. Here is the code I am using:
function hello() {
var p = new XMLHttpRequest();
//uri defined elsewhere
p.open("GET", uri ); //asyncronous request
//p.open("GET", uri, false ); //syncronous request
//This custom header works in the modified HTML test case from above.
p.setRequestHeader('My-Custom-Header', '100');
p.onload = function myonload (){
alert ("Testing");
alert (p.getAllResponseHeaders());
alert (p.responeText);
};
p.send(null);
}
Does anyone know how I can get this to work in the same way as the HTML
example? Any help would be greatly appreciated!
Cheers,
Milamber³
|