mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Issue #2402 - Move code to fill InternalHeaders from an nsIChannel response into utility method. https://bugzilla.mozilla.org/show_bug.cgi?id=1337543
This commit is contained in:
parent
15875f3d8c
commit
14f0bc5e7c
3 changed files with 45 additions and 38 deletions
|
|
@ -12,7 +12,6 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIThreadRetargetableRequest.h"
|
||||
#include "nsIUploadChannel2.h"
|
||||
|
|
@ -449,38 +448,6 @@ FetchDriver::FailWithNetworkError()
|
|||
mChannel = nullptr;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class FillResponseHeaders final : public nsIHttpHeaderVisitor {
|
||||
InternalResponse* mResponse;
|
||||
|
||||
~FillResponseHeaders()
|
||||
{ }
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
explicit FillResponseHeaders(InternalResponse* aResponse)
|
||||
: mResponse(aResponse)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
VisitHeader(const nsACString & aHeader, const nsACString & aValue) override
|
||||
{
|
||||
ErrorResult result;
|
||||
mResponse->Headers()->Append(aHeader, aValue, result);
|
||||
if (result.Failed()) {
|
||||
NS_WARNING(nsPrintfCString("Fetch ignoring illegal header - '%s': '%s'",
|
||||
PromiseFlatCString(aHeader).get(),
|
||||
PromiseFlatCString(aValue).get()).get());
|
||||
result.SuppressException();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(FillResponseHeaders, nsIHttpHeaderVisitor)
|
||||
} // namespace
|
||||
|
||||
NS_IMETHODIMP
|
||||
FetchDriver::OnStartRequest(nsIRequest* aRequest,
|
||||
nsISupports* aContext)
|
||||
|
|
@ -540,11 +507,7 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
|
|||
response = new InternalResponse(responseStatus, statusText,
|
||||
mRequest->GetCredentialsMode());
|
||||
|
||||
RefPtr<FillResponseHeaders> visitor = new FillResponseHeaders(response);
|
||||
rv = httpChannel->VisitResponseHeaders(visitor);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
NS_WARNING("Failed to visit all headers.");
|
||||
}
|
||||
response->Headers()->FillResponseHeaders(httpChannel);
|
||||
|
||||
// If Content-Encoding or Transfer-Encoding headers are set, then the actual
|
||||
// Content-Length (which refer to the decoded data) is obscured behind the encodings.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue