mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 645281: Don't assert if a CORS preflight response contains data. r=bz
This commit is contained in:
parent
8342d4d1e8
commit
0c963366b4
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user