Bug 645281: Don't assert if a CORS preflight response contains data. r=bz

This commit is contained in:
Jonas Sicking 2011-04-11 18:28:28 -07:00
parent 8342d4d1e8
commit 0c963366b4
3 changed files with 16 additions and 1 deletions

View File

@ -59,6 +59,7 @@
#include "prtime.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsStreamUtils.h"
#define PREFLIGHT_CACHE_SIZE 100
@ -1002,7 +1003,8 @@ nsCORSPreflightListener::OnDataAvailable(nsIRequest *aRequest,
PRUint32 sourceOffset,
PRUint32 count)
{
return NS_OK;
PRUint32 totalRead;
return inStr->ReadSegments(NS_DiscardSegment, nsnull, count, &totalRead);
}
NS_IMETHODIMP

View File

@ -151,6 +151,10 @@ function handleRequest(request, response)
response.setHeader("Content-Type", "application/xml", false);
response.write("<res>hello pass</res>\n");
}
if (isPreflight && "preflightBody" in query) {
response.setHeader("Content-Type", "text/plain", false);
response.write(query.preflightBody);
}
}
function sendHttp500(response, text) {

View File

@ -567,6 +567,13 @@ function runTest() {
exposeHeaders: " , ,,y-my-header,z-my-header, ",
expectedResponseHeaders: ["y-my-header"],
},
// Check that sending a body in the OPTIONS response works
{ pass: 1,
method: "DELETE",
allowMethods: "DELETE",
preflightBody: "I'm a preflight response body",
},
];
if (!runPreflightTests) {
@ -635,6 +642,8 @@ function runTest() {
req.url += "&responseHeaders=" + escape(test.responseHeaders.toSource());
if (test.exposeHeaders)
req.url += "&exposeHeaders=" + escape(test.exposeHeaders);
if (test.preflightBody)
req.url += "&preflightBody=" + escape(test.preflightBody);
loaderWindow.postMessage(req.toSource(), origin);
res = eval(yield);