Skip to content
Snippets Groups Projects
Verified Commit 2d85ed67 authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

Bug 40171: Make WebRequest and GeckoWebExecutor First-Party aware

parent 02e87c8f
No related branches found
No related tags found
1 merge request!543Tor Browser 12.5a 102.8.0esr rebase
......@@ -40,6 +40,11 @@ public class WebRequest extends WebMessage {
*/
public final @CacheMode int cacheMode;
/**
* The value of the origin of this request.
*/
public final @Nullable String origin;
/**
* If true, do not use newer protocol features that might have interop problems on the Internet.
* Intended only for use with critical infrastructure.
......@@ -110,6 +115,7 @@ public class WebRequest extends WebMessage {
cacheMode = builder.mCacheMode;
referrer = builder.mReferrer;
beConservative = builder.mBeConservative;
origin = builder.mOrigin;
if (builder.mBody != null) {
body = builder.mBody.asReadOnlyBuffer();
......@@ -125,6 +131,7 @@ public class WebRequest extends WebMessage {
/* package */ int mCacheMode = CACHE_MODE_DEFAULT;
/* package */ String mReferrer;
/* package */ boolean mBeConservative;
/* package */ String mOrigin;
/**
* Construct a Builder instance with the specified URI.
......@@ -235,6 +242,17 @@ public class WebRequest extends WebMessage {
return this;
}
/**
* Set the origin URI.
*
* @param origin A URI String
* @return This Builder instance.
*/
public @NonNull Builder origin(final @Nullable String origin) {
mOrigin = origin;
return this;
}
/** @return A {@link WebRequest} constructed with the values from this Builder instance. */
public @NonNull WebRequest build() {
if (mUri == null) {
......
......@@ -395,6 +395,15 @@ nsresult WebExecutorSupport::CreateStreamLoader(
MOZ_ASSERT(cookieJarSettings);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
if (const auto origin = req->Origin(); origin) {
RefPtr<nsIURI> originUri;
rv = NS_NewURI(getter_AddRefs(originUri), origin->ToString());
NS_ENSURE_SUCCESS(rv, NS_ERROR_MALFORMED_URI);
OriginAttributes attrs = loadInfo->GetOriginAttributes();
attrs.SetFirstPartyDomain(true, originUri);
loadInfo->SetOriginAttributes(attrs);
}
loadInfo->SetCookieJarSettings(cookieJarSettings);
// setup http/https specific things
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment