Bug 1180126 - Read content disposition regardless of content type in imgRequest::PrepareForNewPart. r=tn, a=kglazko
authorSeth Fowler <mark.seth.fowler@gmail.com>
Thu, 09 Jul 2015 09:21:20 -0700
changeset 268801 7e9b8c0e22db8d92667b5b319b4851a8d41d4521
parent 268800 eb3e2d17ba0df9ee1bdf38f6103248c5f63e3b9e
child 268802 d1d1000403e50799bfcdc9c65dc18738095a5ef9
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn, kglazko
bugs1180126
milestone41.0a2
Bug 1180126 - Read content disposition regardless of content type in imgRequest::PrepareForNewPart. r=tn, a=kglazko
image/imgRequest.cpp
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -933,30 +933,30 @@ PrepareForNewPart(nsIRequest* aRequest, 
 
   // Look at the first few bytes and see if we can tell what the data is from
   // that since servers tend to lie. :(
   uint32_t out;
   aInStr->ReadSegments(sniff_mimetype_callback, &closure, aCount, &out);
 
   nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
   if (result.mContentType.IsEmpty()) {
-    nsresult rv = NS_ERROR_FAILURE;
-    if (chan) {
-      rv = chan->GetContentType(result.mContentType);
-      chan->GetContentDispositionHeader(result.mContentDisposition);
-    }
-
+    nsresult rv = chan ? chan->GetContentType(result.mContentType)
+                       : NS_ERROR_FAILURE;
     if (NS_FAILED(rv)) {
       MOZ_LOG(GetImgLog(),
              LogLevel::Error, ("imgRequest::PrepareForNewPart "
                             "-- Content type unavailable from the channel\n"));
       return result;
     }
   }
 
+  if (chan) {
+    chan->GetContentDispositionHeader(result.mContentDisposition);
+  }
+
   MOZ_LOG(GetImgLog(), LogLevel::Debug,
          ("imgRequest::PrepareForNewPart -- Got content type %s\n",
           result.mContentType.get()));
 
   // XXX If server lied about mimetype and it's SVG, we may need to copy
   // the data and dispatch back to the main thread, AND tell the channel to
   // dispatch there in the future.