Bug 454217, httpd.js doesn't handle large body properly, r=sayrer, +change XHR POST test to use request.body

This commit is contained in:
Olli Pettay 2008-09-09 12:32:35 +03:00
Родитель bac2b43e81
Коммит cdbdb36ee4
4 изменённых файлов: 21 добавлений и 11 удалений

Просмотреть файл

@ -186,6 +186,9 @@ _TEST_FILES = test_bug5141.html \
test_bug425201.html \
test_bug431701.html \
test_bug431833.html \
test_bug435425.html \
bug435425.sjs \
bug435425_redirect.sjs \
test_bug438519.html \
test_bug444722.html \
test_bug451376.html \
@ -202,11 +205,6 @@ _TEST_FILES = test_bug5141.html \
test_bug453521.html \
$(NULL)
# bug 451664
# test_bug435425.html \
# bug435425.sjs \
# bug435425_redirect.sjs \
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -1,6 +1,12 @@
function handleRequest(request, response)
{
response.setHeader("Content-Type", "text/plain", false);
response.write(request.queryString);
if (request.method == "GET") {
response.write(request.queryString);
} else {
var rawdata = request.body.purge();
var data = String.fromCharCode.apply(null, rawdata);
response.write(data);
}
}

Просмотреть файл

@ -120,6 +120,7 @@ function start(obj) {
}
try {
var methodIsGet = (obj.method == "GET");
var url;
var privileged = false;
if (obj.testRedirectError) {
@ -129,12 +130,12 @@ function start(obj) {
privileged = true;
} else {
url = "bug435425.sjs";
if (obj.withUpload) {
if (obj.withUpload && methodIsGet) {
url += "?" + obj.withUpload;
}
}
openXHR(xhr, obj.method, url, privileged);
xhr.send(obj.withUpload);
xhr.send(!methodIsGet ? obj.withUpload : null);
if (obj.testAbort) {
xhr.abort();
}

Просмотреть файл

@ -1032,7 +1032,8 @@ RequestReader.prototype =
return;
var moreAvailable = false;
var wasInBody = false;
switch (this._state)
{
case READER_INITIAL:
@ -1043,11 +1044,15 @@ RequestReader.prototype =
moreAvailable = this._processHeaders(input, count);
break;
case READER_IN_BODY:
wasInBody = true;
moreAvailable = this._processBody(input, count);
break;
default:
NS_ASSERT(false);
}
if (this._state == READER_IN_BODY && moreAvailable)
if (!wasInBody && this._state == READER_IN_BODY && moreAvailable)
moreAvailable = this._processBody(input, count);
if (moreAvailable)
@ -1174,7 +1179,7 @@ RequestReader.prototype =
if (this._contentLength > 0)
{
var bodyData = this._data.purge();
if (bodyData.length == 0)
if (!bodyData || bodyData.length == 0)
{
if (count > this._contentLength)
count = this._contentLength;