Commit dff4f6d1 authored by Norisz Fay's avatar Norisz Fay
Browse files

Backed out 2 changesets (bug 1771423) for causing webcompat regressions CLOSED TREE

Backed out changeset c1d1be434427 (bug 1771423)
Backed out changeset 2b7d886f374f (bug 1771423)
parent cd79769a
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1027,13 +1027,13 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest) {
      if (NS_SUCCEEDED(rv) && !contentCharset.IsEmpty()) {
        contentType += ";charset="_ns + contentCharset;
      }
    }

      IgnoredErrorResult result;
      response->Headers()->Append("Content-Type"_ns, contentType, result);
      MOZ_ASSERT(!result.Failed());
    }

    if (contentLength >= 0) {
    if (contentLength > 0) {
      nsAutoCString contentLenStr;
      contentLenStr.AppendInt(contentLength);

+0 −12
Original line number Diff line number Diff line
@@ -26,18 +26,6 @@ BlobURLChannel::BlobURLChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo)

BlobURLChannel::~BlobURLChannel() = default;

NS_IMETHODIMP
BlobURLChannel::SetContentType(const nsACString& aContentType) {
  // If the blob type is empty, set the content type of the channel to the
  // empty string.
  if (aContentType.IsEmpty()) {
    mContentType.Truncate();
    return NS_OK;
  }

  return nsBaseChannel::SetContentType(aContentType);
}

nsresult BlobURLChannel::OpenContentStream(bool aAsync,
                                           nsIInputStream** aResult,
                                           nsIChannel** aChannel) {
+0 −2
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ class BlobURLChannel final : public nsBaseChannel {
 public:
  BlobURLChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo);

  NS_IMETHOD SetContentType(const nsACString& aContentType) override;

 private:
  ~BlobURLChannel() override;

+3 −16
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "nsStreamUtils.h"
#include "nsMimeTypes.h"

namespace mozilla::dom {

@@ -462,21 +461,9 @@ nsresult BlobURLInputStream::StoreBlobImplStream(
    already_AddRefed<BlobImpl> aBlobImpl, const MutexAutoLock& aProofOfLock) {
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
  const RefPtr<BlobImpl> blobImpl = aBlobImpl;
  nsAutoString blobContentType;
  nsAutoCString channelContentType;

  blobImpl->GetType(blobContentType);
  mChannel->GetContentType(channelContentType);
  // A empty content type is the correct channel content type in the case of a
  // fetch of a blob where the type was not set. It is invalid in others cases
  // such as a XHR (See https://xhr.spec.whatwg.org/#response-mime-type). The
  // XMLHttpRequestMainThread will set the channel content type to the correct
  // fallback value before this point, so we need to be careful to only override
  // it when the blob type is valid.
  if (!blobContentType.IsEmpty() ||
      channelContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
    mChannel->SetContentType(NS_ConvertUTF16toUTF8(blobContentType));
  }
  nsAutoString contentType;
  blobImpl->GetType(contentType);
  mChannel->SetContentType(NS_ConvertUTF16toUTF8(contentType));

  auto cleanupOnExit = MakeScopeExit([&] { mChannel = nullptr; });

+1 −1
Original line number Diff line number Diff line
@@ -1889,7 +1889,7 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
  // Fallback to 'application/octet-stream'
  nsAutoCString type;
  channel->GetContentType(type);
  if (type.IsEmpty() || type.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
  if (type.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
    channel->SetContentType(nsLiteralCString(APPLICATION_OCTET_STREAM));
  }

Loading