Bug 967163. Use nsIChannel instead of nsIHttpChannel to contentLength. r=seth

This will let us get the right length for blob uris and is just better.

--HG--
extra : rebase_source : 4d898ab29c5e1d146d7b543bd1afdc6f6815f28c
This commit is contained in:
Jeff Muizelaar 2014-02-10 14:54:23 -05:00
parent 40db431b9e
commit 5c27c081b4

View File

@ -143,14 +143,12 @@ SaturateToInt32(int64_t val)
uint32_t
GetContentSize(nsIRequest* aRequest)
{
// Use content-length as a size hint for http channels.
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
if (httpChannel) {
nsAutoCString contentLength;
nsresult rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-length"),
contentLength);
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel) {
int64_t size;
nsresult rv = channel->GetContentLength(&size);
if (NS_SUCCEEDED(rv)) {
return std::max(contentLength.ToInteger(&rv), 0);
return std::max(SaturateToInt32(size), 0);
}
}