From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- netwerk/base/nsIBaseChannel.idl | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 netwerk/base/nsIBaseChannel.idl (limited to 'netwerk/base/nsIBaseChannel.idl') diff --git a/netwerk/base/nsIBaseChannel.idl b/netwerk/base/nsIBaseChannel.idl new file mode 100644 index 0000000000..5f2fe1517d --- /dev/null +++ b/netwerk/base/nsIBaseChannel.idl @@ -0,0 +1,63 @@ +/* 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 "nsISupports.idl" + +%{C++ +#include "mozilla/dom/MimeType.h" +#include "mozilla/net/ContentRange.h" +%} + +/** + * The nsIBaseChannel interface allows C++ code to query the interface + * of channels safely to gain access to content range functionality. + * This allows subclasses to optionally handle range-requests on their + * types using fetch/XMLHttpRequest even if they are not accessed via + * HTTP and therefore normally do not have support for headers. + */ + +native ContentRangeRef(RefPtr); +native MimeTypeRef(RefPtr>); + +[uuid(036d5cd7-9a53-40e3-9c72-c2ffaa15aa2b)] +interface nsIBaseChannel : nsISupports { + + /** + * Used by fetch and XMLHttpRequest to get only the range specified in the + * Range request header (if given) for the response body (e.g, for blob URLs) + */ + attribute ContentRangeRef contentRange; + + /** + * Used by fetch and XMLHttpRequest to get the standards-compliant value they + * should set for the Content-Type header on response (if nullptr, they will + * use Firefox-specific values from nsIChannel::GetContentType and GetCharset). + */ + attribute MimeTypeRef fullMimeType; + +%{C++ + RefPtr ContentRange() { + RefPtr range; + mozilla::Unused << GetContentRange(&range); + return range; + } + + bool SetContentRangeFromHeader(const nsACString& aHeader, uint64_t aSize) { + RefPtr range = + new mozilla::net::ContentRange(aHeader, aSize); + if (!range->IsValid()) { + return false; + } + SetContentRange(range); + return true; + } + + RefPtr FullMimeType() { + RefPtr type; + mozilla::Unused << GetFullMimeType(&type); + return type; + } +%} + +}; -- cgit v1.2.3