summaryrefslogtreecommitdiff
path: root/dom/fetch
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-27 23:22:06 -0500
committerBrian Smith <brian@dbsoft.org>2023-09-27 23:22:06 -0500
commit03ec9c095b8adc0d1fc2c528112e5eb0f6dad6a3 (patch)
treec9de145426f43aa97a61803ef9a63799d23bd7f3 /dom/fetch
parent24edfc1652a6be18d053976b26a26ac331ab6661 (diff)
downloaduxp-03ec9c095b8adc0d1fc2c528112e5eb0f6dad6a3.tar.gz
Issue #1442 - Part 10b - Use nsIXHRSendable instead Blob/FormData/URLSearchParams.
https://bugzilla.mozilla.org/show_bug.cgi?id=1329298 Pre-requisite for Part 11.
Diffstat (limited to 'dom/fetch')
-rw-r--r--dom/fetch/BodyExtractor.cpp30
-rw-r--r--dom/fetch/BodyExtractor.h4
-rw-r--r--dom/fetch/Fetch.cpp15
3 files changed, 8 insertions, 41 deletions
diff --git a/dom/fetch/BodyExtractor.cpp b/dom/fetch/BodyExtractor.cpp
index 889526314e..89c9c20ddf 100644
--- a/dom/fetch/BodyExtractor.cpp
+++ b/dom/fetch/BodyExtractor.cpp
@@ -193,36 +193,6 @@ BodyExtractor<nsIInputStream>::GetAsStream(nsIInputStream** aResult,
}
template<> nsresult
-BodyExtractor<Blob>::GetAsStream(nsIInputStream** aResult,
- uint64_t* aContentLength,
- nsACString& aContentTypeWithCharset,
- nsACString& aCharset) const
-{
- return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
- aCharset);
-}
-
-template<> nsresult
-BodyExtractor<FormData>::GetAsStream(nsIInputStream** aResult,
- uint64_t* aContentLength,
- nsACString& aContentTypeWithCharset,
- nsACString& aCharset) const
-{
- return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
- aCharset);
-}
-
-template<> nsresult
-BodyExtractor<URLSearchParams>::GetAsStream(nsIInputStream** aResult,
- uint64_t* aContentLength,
- nsACString& aContentTypeWithCharset,
- nsACString& aCharset) const
-{
- return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
- aCharset);
-}
-
-template<> nsresult
BodyExtractor<nsIXHRSendable>::GetAsStream(nsIInputStream** aResult,
uint64_t* aContentLength,
nsACString& aContentTypeWithCharset,
diff --git a/dom/fetch/BodyExtractor.h b/dom/fetch/BodyExtractor.h
index 7d4bfd068e..d6b79b0349 100644
--- a/dom/fetch/BodyExtractor.h
+++ b/dom/fetch/BodyExtractor.h
@@ -24,8 +24,8 @@ public:
};
// The implementation versions of this template are:
-// ArrayBuffer, ArrayBufferView, Blob, FormData, nsAString, nsIDocument,
-// nsIInputStream, nsIXHRSendable, URLSearchParams
+// ArrayBuffer, ArrayBufferView, nsIXHRSendable (Blob, FormData,
+// URLSearchParams), nsAString, nsIDocument, nsIInputStream
template<typename Type>
class BodyExtractor final : public BodyExtractorBase
{
diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
index de54b6094e..a831843a96 100644
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -746,13 +746,13 @@ ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDa
}
if (aBodyInit.IsBlob()) {
Blob& blob = aBodyInit.GetAsBlob();
- BodyExtractor<Blob> body(&blob);
+ BodyExtractor<nsIXHRSendable> body(&blob);
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}
if (aBodyInit.IsFormData()) {
FormData& formData = aBodyInit.GetAsFormData();
- BodyExtractor<FormData> body(&formData);
+ BodyExtractor<nsIXHRSendable> body(&formData);
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}
@@ -763,7 +763,7 @@ ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDa
}
if (aBodyInit.IsURLSearchParams()) {
URLSearchParams& usp = aBodyInit.GetAsURLSearchParams();
- BodyExtractor<URLSearchParams> body(&usp);
+ BodyExtractor<nsIXHRSendable> body(&usp);
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}
@@ -795,14 +795,12 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
charset);
}
if (aBodyInit.IsBlob()) {
- Blob& blob = aBodyInit.GetAsBlob();
- BodyExtractor<Blob> body(&blob);
+ BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsBlob());
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}
if (aBodyInit.IsFormData()) {
- FormData& formData = aBodyInit.GetAsFormData();
- BodyExtractor<FormData> body(&formData);
+ BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsFormData());
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}
@@ -812,8 +810,7 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
charset);
}
if (aBodyInit.IsURLSearchParams()) {
- URLSearchParams& usp = aBodyInit.GetAsURLSearchParams();
- BodyExtractor<URLSearchParams> body(&usp);
+ BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsURLSearchParams());
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
charset);
}