Closed
Bug 504978
Opened 17 years ago
Closed 15 years ago
XMLHttpRequest reponds with Cteonnt-Length instead of Content-Length while the status = 0 and readyState=4
Categories
(Firefox :: File Handling, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: bhrdesign, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1
After creating an XMLHttpRequest and sending it, the readyState of the request is set to 4, and the status is 0. The responseText is empty. If you view the Response headers for the request in FireBug, you will notice that the response header for the Content-Length is incorrectly spelled as "Cteonnt-Length", causing the request to fail.
Reproducible: Always
Steps to Reproduce:
1. Create an XMLHttpRequest and send it.
2. Load the page in browser.
3. View response headers in FireBug
Actual Results:
XMLHttpRequest status is never set to 200, and responseText/XML is null.
Expected Results:
Set Cteonnt-Length to Content-Length and set the responseText to the data from request.
Comment 1•17 years ago
|
||
The Cteonnt-Length header is a mozilla.org-specific thing. mozilla.org is actually sending it in the response. Weird.
The status doesn't get set to 200 because it's a cross-site request.
Comment 2•16 years ago
|
||
[A] Probelm description:
========================
I have also the same experience, they are:
(1) responseText = '' (expected xmlHttpRequest.responseText = '<h1>Hello World</h1>')
(2) status = 0 (expected HTTP code 200)
(3) while according to the wireshark trace FireFox(FF) v 3.5.5 receives response '<h1>Hello World</h1>' and http-code = 200
[B] Wireshark TRACE:
====================
No. Time Source Destination Protocol Info
1590 74.368895 192.168.0.100 192.168.0.104 TCP irdmi > hp-webadmin [PSH, ACK] Seq=1 Ack=411 Win=64240 Len=36
0000 48 54 54 50 2f 31 2e 30 20 32 30 30 20 53 63 72 HTTP/1.0 200 Scr 0010 69 70 74 20 6f 75 74 70 75 74 20 66 6f 6c 6c 6f ipt output follo
0020 77 73 0d 0a ws..
No. Time Source Destination Protocol Info
1601 74.625265 192.168.0.100 192.168.0.104 TCP irdmi > hp-webadmin [FIN, PSH, ACK] Seq=111 Ack=411 Win=64240 Len=90
0000 43 6f 6e 74 65 6e 74 2d 74 79 70 65 3a 20 74 65 Content-type: te
0010 78 74 2f 68 74 6d 6c 3b 63 68 61 72 73 65 74 3d xt/html;charset=
0020 75 74 66 2d 38 0d 0a 0a 0a 52 45 51 55 45 53 54 utf-8....REQUEST
0030 5f 4d 45 54 48 4f 44 3a 20 47 45 54 0a 56 61 6c _METHOD: GET.Val
0040 75 65 73 3a 0a 3c 68 31 3e 48 65 6c 6c 6f 20 57 ues:.<h1>Hello W
0050 6f 72 6c 64 3c 2f 68 31 3e 0a orld</h1>.
[C] CONFIGURATION:
=================
PC1: 192.168.0.100
Windows Vista; CGIHttpServer.py - CGI-HTTP server/cgi-bin/ajax2a1.py
PC2: 192.168.0.104
Windows XP; Firefox v3.5.5 - ajax2a2.html
[D] CGI HTTP SERVER:
====================
Serving HTTP on 0.0.0.0 port 8000 ...
"GET /cgi-bin/ajax2a1.py HTTP/1.1" 200 -
command: C:\Python25\python.exe -u C:\DKw_Ajax\01_Study_Ajax\01_ajaxTrials\cgi-bin\ajax2a1.py ""
CGI script exited OK
[E] CGI SCRIPT: ajax2a1.py
==========================
#!/bin/env python
# http://code.activestate.com/recipes/440637/
import cgi
from os import environ
import cgitb
cgitb.enable()
print "Content-type: text/html;charset=utf-8\r\n"
print
print "REQUEST_METHOD:", environ["REQUEST_METHOD"]
print "Values:"
print "<h1>Hello World</h1>"
[F] ajax2a2.html
================
<html>
<head>
<title>Ajax mechanism example</title>
<script language="JavaScript">
var xmlHttp;
function fetchData(url, objectID) {
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function(){
alert('onreadystatechange: '+ xmlHttp.readyState + ' responseText: ' + xmlHttp.responseText);
if (xmlHttp.readyState == 4){
if (xmlHttp.responseText != '')
document.getElementById("message").innerHTML = xmlHttp.responseText;
else
document.getElementById("message").innerHTML = '<h1>ERROR!!</h1>';
}
}
xmlHttp.open('GET', url, true);
alert('send'); // first alert, then see above onreadystatechange alerts
xmlHttp.send(null);
alert('HTTP status: '+ xmlHttp.status);
}
</script>
</head>
<body>
<div id="clickhere"
<input type = "button" name = "button1" value = "click here" onclick="fetchData('http://192.168.0.100:8000/cgi-bin/ajax2a1.py', 'message')">
</div>
<div id="message"> </div>
</body>
</html>
Reverse-proxies often mangle strings (like 'Content-length') to nullify their effect. Mangling avoids having to copy the response.
Comment 4•15 years ago
|
||
So comment 1 seems right.. Cteonnt-Length is intentional on mozilla.org (see also bug 503175). Plus the testcase is 404.
Comment 2 is a different issue. Please retest with Firefox 4 beta and open a new bug if you still see the issue.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•