Bug 813433 - Make nsMediaSniffer accept null request arguments; r=bzbarsky

This patch will make the content sniffer useful to sniff the mimetype of
in-memory media buffers.
This commit is contained in:
Ehsan Akhgari 2012-11-20 00:01:30 -05:00
parent 334ae7f032
commit e55fd9da0a

View File

@ -75,16 +75,15 @@ nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
// For media, we want to sniff only if the Content-Type is unknown, or if it
// is application/octet-stream.
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (!channel) {
return NS_ERROR_NOT_AVAILABLE;
}
nsAutoCString contentType;
nsresult rv = channel->GetContentType(contentType);
NS_ENSURE_SUCCESS(rv, rv);
if (!contentType.IsEmpty() &&
!contentType.EqualsLiteral(APPLICATION_OCTET_STREAM) &&
!contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
return NS_ERROR_NOT_AVAILABLE;
if (channel) {
nsAutoCString contentType;
nsresult rv = channel->GetContentType(contentType);
NS_ENSURE_SUCCESS(rv, rv);
if (!contentType.IsEmpty() &&
!contentType.EqualsLiteral(APPLICATION_OCTET_STREAM) &&
!contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
return NS_ERROR_NOT_AVAILABLE;
}
}
const uint32_t clampedLength = NS_MIN(aLength, MAX_BYTES_SNIFFED);