mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
dbe1b78cc2
Use nsCrossSiteListenerProxy.h helpers to implement CORS support. Several CORS fixes and lots of CORS tests. Fixes: Use empty string stream if response has no stream. Parse Access-Control-Expose-Headers correctly. Copy over remaining InternalRequest constructor attributes and set unsafe request flag. Call FailWithNetworkError() in more cases. Add non-simple Request headers to unsafeHeaders list for CORS check. Do not AsyncOpen channel directly when CORS preflight is required. Fix check for simple request method (was checking the opposite condition). --HG-- extra : rebase_source : 4b08f6a5959e470394c88249b39464b3b7d20948
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "InternalRequest.h"
|
|
|
|
#include "nsIContentPolicy.h"
|
|
#include "nsIDocument.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
#include "mozilla/dom/ScriptSettings.h"
|
|
#include "mozilla/dom/workers/Workers.h"
|
|
|
|
#include "WorkerPrivate.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
// The global is used to extract the principal.
|
|
already_AddRefed<InternalRequest>
|
|
InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult& aRv) const
|
|
{
|
|
nsRefPtr<InternalRequest> copy = new InternalRequest();
|
|
copy->mURL.Assign(mURL);
|
|
copy->SetMethod(mMethod);
|
|
copy->mHeaders = new InternalHeaders(*mHeaders);
|
|
copy->SetUnsafeRequest();
|
|
|
|
copy->mBodyStream = mBodyStream;
|
|
copy->mForceOriginHeader = true;
|
|
// The "client" is not stored in our implementation. Fetch API users should
|
|
// use the appropriate window/document/principal and other Gecko security
|
|
// mechanisms as appropriate.
|
|
copy->mSameOriginDataURL = true;
|
|
copy->mPreserveContentCodings = true;
|
|
// The default referrer is already about:client.
|
|
|
|
copy->mContext = nsIContentPolicy::TYPE_FETCH;
|
|
copy->mMode = mMode;
|
|
copy->mCredentialsMode = mCredentialsMode;
|
|
copy->mCacheMode = mCacheMode;
|
|
return copy.forget();
|
|
}
|
|
|
|
InternalRequest::~InternalRequest()
|
|
{
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|