I'm having some problems with a weird HTTP status code in MSIE8.
I send an HTTP GET to the following URL:
/cgi-bin/objectBrowser/snap.pl?file_key=28
From Fiddler, I can see that I'm getting the following Raw response:
HTTP/1.1 302 Found
Date: Fri, 27 May 2011 20:24:38 GMT
Server: Apache/2.2.3 (Red Hat)
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 61
Location: /cgi-bin/objectBrowser/workWithSnap.pl?snapKey=32
This was generated using the following Perl:
print $cgi->header( -status => '302 Found' );
print "Location: /cgi-bin/objectBrowser/workWithSnap.pl?snapKey=$snap_key\n\n";
I'm using jQuery to access it, in the following way:
jQuery.ajax({
type : "GET",
url : "/cgi-bin/objectBrowser/file.pl?pmr=" + request.pmr
+ "&filename=" + request.filename,
statusCode : {
200 : function(file_info) {
if (file_info.status == "parsing") {
jQuery('div#updates').append('<div class="information">No snap yet, but file <i>has</i> been registered already.</div>');
jQuery('div#updates').append('<div class="waiting">Awaiting job completion...</div>');
jQuery.getJSON("/cgi-bin/objectBrowser/job.pl?file_key=" + file_info.file_key, function(job_info) {
poll_for_job_completion(job_info);
});
} else {
jQuery.ajax({
type : "GET",
url : "/cgi-bin/objectBrowser/snap.pl?file_key=" + file_info.file_key,
statusCode : {
302 : function(xhr) {
jQuery('div#updates').append('<div class="information">Redirecting to snap</div>');
alert("302: "+ xhr.responseText);
process_302(xhr.responseText);
}
}
});
}
},
302 : function(xhr) {
alert("302: "+ xhr.responseText);
process_302(xhr.responseText);
},
404 : register_file
}
});
Finally, I have the following to help with debug:
jQuery('body').ajaxComplete(function(e,a,o) {
console.log('Event: %o\nXHR: %o\nOptions: %o',e,a,o);
console.log(o.url);
console.log(a.status);
console.log(a.responseText);
});
This all works fine in Firefox and Chrome, but in MSIE, where I normally get a status of 302
in response to my request for snap.pl
, I'm getting a response of 12150
. The best hit I've found is on MSDN, which suggests that this is ERROR_HTTP_HEADER_NOT_FOUND
... but the Headers look good to me.
I can't figure out what's going wrong here... does anyone see anything that I may be overlooking?
Problem solved!
The bug was the header generation.
The resulting HTTP header has a big gap in it and MSIE8 is interpreting Location
as being in the body, not the header.
By using
print $cgi->redirect( -uri => "/cgi-bin/objectBrowser/workWithSnap.pl?snapKey=$snap_key");
the header is created correctly and I get sensible behaviour again
HTTP/1.1 302 Found
Date: Fri, 27 May 2011 21:00:51 GMT
Server: Apache/2.2.3 (Red Hat)
Location: /cgi-bin/objectBrowser/workWithSnap.pl?snapKey=32
Content-Length: 0
Connection: close
Content-Type: text/plain; charset=UTF-8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With