mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +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
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
|
|
@ -478,6 +479,48 @@ InternalHeaders::Fill(const Record<nsCString, nsCString>& aInit, ErrorResult& aR
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class FillHeaders final : public nsIHttpHeaderVisitor
|
||||
{
|
||||
RefPtr<InternalHeaders> mInternalHeaders;
|
||||
|
||||
~FillHeaders() = default;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
explicit FillHeaders(InternalHeaders* aInternalHeaders)
|
||||
: mInternalHeaders(aInternalHeaders)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(mInternalHeaders);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
VisitHeader(const nsACString& aHeader, const nsACString& aValue) override
|
||||
{
|
||||
IgnoredErrorResult result;
|
||||
mInternalHeaders->Append(aHeader, aValue, result);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(FillHeaders, nsIHttpHeaderVisitor)
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
InternalHeaders::FillResponseHeaders(nsIRequest* aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
|
||||
if (!httpChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<FillHeaders> visitor = new FillHeaders(this);
|
||||
httpChannel->VisitResponseHeaders(visitor);
|
||||
}
|
||||
|
||||
bool
|
||||
InternalHeaders::HasOnlySimpleHeaders() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue