Files
palemoon27/dom/fetch/InternalResponse.cpp
T
roytam1 f468c29a62 import changes from `dev' branch of rmottola/Arctic-Fox:
- hState() in iframe fails when reloading with CTRL+F5, r=bz (2afcd259da)
- Bug 1207137 - Add an error code for weak crypto override. r=bz (27b270707b)
- Bug 1170488 - Add browser_multiple_pushState.js regression test. r=smaug (157672edb9)
- Bug 1206879 - fire onlocationchange from pushState in frames when the URI changes, r=smaug (deb2b21372)
- Bug 1200119 - Add a way to create usable markers from different threads, r=tromey (530f3a5eba)
- fix include (4c9ffeff29)
- Bug 1202657 - Add markers for workers' message passing and serialization/deserialization, r=smaug, jsantell, tromey, ejpbruel (4b911a9422)
- Bug 1160307 - capture async stack frames on Javascript timeline markers. r=fitzgen, r=smaug r=Paolo (04a700e4d1)
- fix linux toolbar icons (ffd49a4dff)
- partial revert or Mac won't package (cbdaa8382d)
- fix most icons on Mac except download (07c700aa76)
- Bug 718637 - Notify that the document is loaded. r=MarcoZ (7b35f20bef)
- Bug 1177640 - [Mac] Do not expose HTML table semantics for "layout" tables. r=surkov (8c898e78a3)
- Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov (6aac88d16f)
- Bug 1178272 - Move table semantics to a separate mozTableAccessible.mm file. r=surkov (0ee62ef8e8)
- cleanup trailing spaces (9f53855fbd)
- bug 1213402 - separate value change events into text value changes and numeric value changes r=davidb (c94cc113ad)
- bug 1213402 - Fire numeric value change events for proxies r=davidb (cb58d2b126)
- Bug 1213382 - proxy more accessible selection methods, r=tbsaunde (68f9f6ef57)
- bug 1170049 - check if document tree is correct before cleaning it upr=lsocks (d92ae58a5c)
- bug 1185550 - Make sure to correctly handle invalid RecvBindChildDoc and PDocAccessibleConstructor messages from the child process r=lsocks (f70e1b0d1a)
- bug 1185726 - avoid killing the child process when it sends the parent events with bad IDs r=lsocks (9447b7c6d7)
- bug 1185726 - follow up to deal with -Wunused warning r=me landing on a CLOSED TREE (3cd4bbb768)
- bug 1188415 - add document tree consistancy checks to more message handlers r=davidb (1bc9c578ee)
- bug 1194853 - pass the correct interfaces to Proxycreated when creating documents r=davidb (f1748d0892)
- bug 1188415 - make CheckDocTree return if the document tree is in a sane state (9a2b452392)
- bug 1221551 - unbind child documents before rebinding them r=davidb (06737cdb16)
- bug 1204070 - add a little more checking to proxy subtree removal r=davidb (24aca334a6)
- bug 1164976 - Make DocAccessibleParent::GetAccessible return itself when appropriate r=davidb (9e88a4fa99)
- bug 1207862 - make it possible to traverse down the tree of proxied documents r=davidb (41a684a249)
- bug 1209147 - make proxying of Accessible::TakeFocus() async r=davidb (96b8ba4f45)
- bug 1186536 - make SerializeTree() use IsOuterDoc() to check if an accessible is an outer doc r=davidb (b661e115f3)
- bug 1162543 - IDs not mapping to accessibles shouldn't cause ipc calls to fail r=davidb (7f9ba71016)
- bug 1170595 - always use IdToAccessible to convert ids to accessibles r=lsocks (c21659779b)
- Bug 1207311 - No need for \!nsAccUtils::MustPrune(acc) in DocAccessibleChild::RecvExtents, r=tbsaunde (69f7ebc23d)
- Bug 1100602 - Kill child if accessibility ID is re-used (r=trevor) (9955223c4e)
- bug 1213606 - assert that we don't destroy a document's proxy until we destroy all of its children r=davidb (f7ab023489)
- bug 1191433 - use ProxyAccessible::AsDoc() in ProxyAccessible::Shutdown() r=lsocks (e6204e7847)
- bug 1210447 - fix ProxyAccessible::EmbeddedChildAt() on proxies of outerDocs r=davidb (d5acdc0507)
- Bug 1212904 P0 Do not abuse fetch response tainting to create opaqueredirect responses. r=ehsan (36f1f393b6)
- Bug 1212904 P3 Make FetchDriver look for the channel Tainting value. r=ehsan (037227c5a8)
- Bug 1212904 P4 Set channel tainting in FetchEvent.respondWith(). r=ehsan (8fcd1f64d6)
- Bug 1212904 P5 Make XHR respect channel tainting. r=ehsan r=sicking (ea03564fde)
- Bug 1204596 - Part 1: Avoid overriding the channel final URI when it gets intercepted; r=nsm,bkelly (da18cfd294)
- Bug 1204596 - Part 2: Update the schema of the DOM Cache database to remove the response_redirected and response_redirected_url columns; r=bkelly (eabaae5330)
- Bug 1204596 - Part 3: Store the responses with manual redirect in the tests added for bug 1164397; r=bkelly (8996f84c1c)
- Bug 1204596 - Part 4: Disable test_fetch_cors.html on b2g; r=bkelly (eb0a61aae1)
- Bug 1212904 P6 Check for CORS response type in fetch mochitests. r=sicking (157b516434)
- Bug 1212904 P7 Verify xhr respects service worker CORS tainting. r=ehsan (e6f347d6d3)
- Bug 1217501 P1 Expose Accept and Accept-Language to service worker FetchEvent.request. r=mcmanus (07722f151e)
- Bug 1217501 P2 Send */* for fetch() default Accept header. r=ehsan (2bc362d107)
- Bug 1130803 - Use non-blocking input for Fetch synthetization pipe, r=bkelly,ehsan (f926b74fed)
2022-11-08 14:20:19 +08:00

175 lines
4.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "InternalResponse.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/InternalHeaders.h"
#include "mozilla/dom/cache/CacheTypes.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "nsIURI.h"
#include "nsStreamUtils.h"
namespace mozilla {
namespace dom {
InternalResponse::InternalResponse(uint16_t aStatus, const nsACString& aStatusText)
: mType(ResponseType::Default)
, mStatus(aStatus)
, mStatusText(aStatusText)
, mHeaders(new InternalHeaders(HeadersGuardEnum::Response))
{
}
InternalResponse::~InternalResponse()
{
}
already_AddRefed<InternalResponse>
InternalResponse::Clone()
{
RefPtr<InternalResponse> clone = CreateIncompleteCopy();
clone->mHeaders = new InternalHeaders(*mHeaders);
if (mWrappedResponse) {
clone->mWrappedResponse = mWrappedResponse->Clone();
MOZ_ASSERT(!mBody);
return clone.forget();
}
if (!mBody) {
return clone.forget();
}
nsCOMPtr<nsIInputStream> clonedBody;
nsCOMPtr<nsIInputStream> replacementBody;
nsresult rv = NS_CloneInputStream(mBody, getter_AddRefs(clonedBody),
getter_AddRefs(replacementBody));
if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; }
clone->mBody.swap(clonedBody);
if (replacementBody) {
mBody.swap(replacementBody);
}
return clone.forget();
}
already_AddRefed<InternalResponse>
InternalResponse::BasicResponse()
{
MOZ_ASSERT(!mWrappedResponse, "Can't BasicResponse a already wrapped response");
RefPtr<InternalResponse> basic = CreateIncompleteCopy();
basic->mType = ResponseType::Basic;
basic->mHeaders = InternalHeaders::BasicHeaders(Headers());
basic->mWrappedResponse = this;
return basic.forget();
}
already_AddRefed<InternalResponse>
InternalResponse::CORSResponse()
{
MOZ_ASSERT(!mWrappedResponse, "Can't CORSResponse a already wrapped response");
RefPtr<InternalResponse> cors = CreateIncompleteCopy();
cors->mType = ResponseType::Cors;
cors->mHeaders = InternalHeaders::CORSHeaders(Headers());
cors->mWrappedResponse = this;
return cors.forget();
}
void
InternalResponse::SetPrincipalInfo(UniquePtr<mozilla::ipc::PrincipalInfo> aPrincipalInfo)
{
mPrincipalInfo = Move(aPrincipalInfo);
}
nsresult
InternalResponse::StripFragmentAndSetUrl(const nsACString& aUrl)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIURI> iuri;
nsresult rv;
rv = NS_NewURI(getter_AddRefs(iuri), aUrl);
if(NS_WARN_IF(NS_FAILED(rv))){
return rv;
}
nsCOMPtr<nsIURI> iuriClone;
// We use CloneIgnoringRef to strip away the fragment even if the original URI
// is immutable.
rv = iuri->CloneIgnoringRef(getter_AddRefs(iuriClone));
if(NS_WARN_IF(NS_FAILED(rv))){
return rv;
}
nsCString spec;
rv = iuriClone->GetSpec(spec);
if(NS_WARN_IF(NS_FAILED(rv))){
return rv;
}
SetUrl(spec);
return NS_OK;
}
LoadTainting
InternalResponse::GetTainting() const
{
switch (mType) {
case ResponseType::Cors:
return LoadTainting::CORS;
case ResponseType::Opaque:
return LoadTainting::Opaque;
default:
return LoadTainting::Basic;
}
}
already_AddRefed<InternalResponse>
InternalResponse::OpaqueResponse()
{
MOZ_ASSERT(!mWrappedResponse, "Can't OpaqueResponse a already wrapped response");
RefPtr<InternalResponse> response = new InternalResponse(0, EmptyCString());
response->mType = ResponseType::Opaque;
response->mTerminationReason = mTerminationReason;
response->mChannelInfo = mChannelInfo;
if (mPrincipalInfo) {
response->mPrincipalInfo = MakeUnique<mozilla::ipc::PrincipalInfo>(*mPrincipalInfo);
}
response->mWrappedResponse = this;
return response.forget();
}
already_AddRefed<InternalResponse>
InternalResponse::OpaqueRedirectResponse()
{
MOZ_ASSERT(!mWrappedResponse, "Can't OpaqueRedirectResponse a already wrapped response");
RefPtr<InternalResponse> response = OpaqueResponse();
response->mType = ResponseType::Opaqueredirect;
response->mURL = mURL;
return response.forget();
}
already_AddRefed<InternalResponse>
InternalResponse::CreateIncompleteCopy()
{
RefPtr<InternalResponse> copy = new InternalResponse(mStatus, mStatusText);
copy->mType = mType;
copy->mTerminationReason = mTerminationReason;
copy->mURL = mURL;
copy->mChannelInfo = mChannelInfo;
if (mPrincipalInfo) {
copy->mPrincipalInfo = MakeUnique<mozilla::ipc::PrincipalInfo>(*mPrincipalInfo);
}
return copy.forget();
}
} // namespace dom
} // namespace mozilla