Bug 1109751 - Request and Response constructors should set mime type. r=baku

This commit is contained in:
Nikhil Marathe 2015-02-03 12:59:32 -08:00
parent 833423e628
commit e601432aec
4 changed files with 12 additions and 10 deletions

View File

@ -1627,15 +1627,15 @@ FetchBody<Response>::ConsumeBody(ConsumeType aType, ErrorResult& aRv);
template <class Derived>
void
FetchBody<Derived>::SetMimeType(ErrorResult& aRv)
FetchBody<Derived>::SetMimeType()
{
// Extract mime type.
ErrorResult result;
nsTArray<nsCString> contentTypeValues;
MOZ_ASSERT(DerivedClass()->GetInternalHeaders());
DerivedClass()->GetInternalHeaders()->GetAll(NS_LITERAL_CSTRING("Content-Type"), contentTypeValues, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
DerivedClass()->GetInternalHeaders()->GetAll(NS_LITERAL_CSTRING("Content-Type"),
contentTypeValues, result);
MOZ_ALWAYS_TRUE(!result.Failed());
// HTTP ABNF states Content-Type may have only one value.
// This is from the "parse a header value" of the fetch spec.
@ -1647,10 +1647,10 @@ FetchBody<Derived>::SetMimeType(ErrorResult& aRv)
template
void
FetchBody<Request>::SetMimeType(ErrorResult& aRv);
FetchBody<Request>::SetMimeType();
template
void
FetchBody<Response>::SetMimeType(ErrorResult& aRv);
FetchBody<Response>::SetMimeType();
} // namespace dom
} // namespace mozilla

View File

@ -160,7 +160,7 @@ protected:
virtual ~FetchBody();
void
SetMimeType(ErrorResult& aRv);
SetMimeType();
private:
enum ConsumeType
{

View File

@ -34,6 +34,7 @@ Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest)
, mOwner(aOwner)
, mRequest(aRequest)
{
SetMimeType();
}
Request::~Request()
@ -264,7 +265,7 @@ Request::Constructor(const GlobalObject& aGlobal,
}
nsRefPtr<Request> domRequest = new Request(global, request);
domRequest->SetMimeType(aRv);
domRequest->SetMimeType();
return domRequest.forget();
}

View File

@ -38,6 +38,7 @@ Response::Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse
, mOwner(aGlobal)
, mInternalResponse(aInternalResponse)
{
SetMimeType();
}
Response::~Response()
@ -188,7 +189,7 @@ Response::Constructor(const GlobalObject& aGlobal,
}
}
r->SetMimeType(aRv);
r->SetMimeType();
return r.forget();
}