[poppler] 2 commits - poppler/CachedFile.cc poppler/CurlCachedFile.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Mar 13 07:50:00 PDT 2011


 poppler/CachedFile.cc     |   10 ++++++++--
 poppler/CurlCachedFile.cc |   14 ++++++++++----
 2 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 1acbb01e72a22f70f00dc058ff206e3bc05bc0ab
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Mar 13 14:49:48 2011 +0000

    (C) years

diff --git a/poppler/CachedFile.cc b/poppler/CachedFile.cc
index 79218e6..3933830 100644
--- a/poppler/CachedFile.cc
+++ b/poppler/CachedFile.cc
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2009 Stefan Thomas <thomas at eload24.com>
-// Copyright 2010 Hib Eris <hib at hiberis.nl>
+// Copyright 2010, 2011 Hib Eris <hib at hiberis.nl>
 // Copyright 2010 Albert Astals Cid <aacid at kde.org>
 //
 //========================================================================
diff --git a/poppler/CurlCachedFile.cc b/poppler/CurlCachedFile.cc
index 8ddf9a2..26e59e3 100644
--- a/poppler/CurlCachedFile.cc
+++ b/poppler/CurlCachedFile.cc
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2009 Stefan Thomas <thomas at eload24.com>
-// Copyright 2010 Hib Eris <hib at hiberis.nl>
+// Copyright 2010, 2011 Hib Eris <hib at hiberis.nl>
 // Copyright 2010 Albert Astals Cid <aacid at kde.org>
 //
 //========================================================================
commit bc8aeb269aa92406081f749064ceff75bb3145e7
Author: Hib Eris <hib at hiberis.nl>
Date:   Sat Mar 12 23:17:59 2011 +0100

    Check response code of libcurl call

diff --git a/poppler/CachedFile.cc b/poppler/CachedFile.cc
index f1e49d1..79218e6 100644
--- a/poppler/CachedFile.cc
+++ b/poppler/CachedFile.cc
@@ -29,7 +29,13 @@ CachedFile::CachedFile(CachedFileLoader *cachedFileLoaderA, GooString *uriA)
   length = loader->init(uri, this);
   refCnt = 1;
 
-  chunks->resize(length/CachedFileChunkSize + 1);
+  if (length != ((size_t) -1)) {
+    chunks->resize(length/CachedFileChunkSize + 1);
+  }
+  else {
+    error(-1, "Failed to initialize file cache for '%s'.", uri->getCString());
+    chunks->resize(0);
+  }
 }
 
 CachedFile::~CachedFile()
diff --git a/poppler/CurlCachedFile.cc b/poppler/CurlCachedFile.cc
index bd50241..8ddf9a2 100644
--- a/poppler/CurlCachedFile.cc
+++ b/poppler/CurlCachedFile.cc
@@ -39,6 +39,7 @@ size_t
 CurlCachedFileLoader::init(GooString *urlA, CachedFile *cachedFileA)
 {
   double contentLength = -1;
+  long code = 0;
   size_t size;
 
   url = urlA;
@@ -50,11 +51,16 @@ CurlCachedFileLoader::init(GooString *urlA, CachedFile *cachedFileA)
   curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &noop_cb);
   curl_easy_perform(curl);
-  curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &contentLength);
+  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
+  if (code) {
+     curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &contentLength);
+     size = contentLength;
+  } else {
+     error(-1, "Failed to get size of '%s'.", url->getCString());
+     size = -1;
+  }
   curl_easy_reset(curl);
 
-  size = contentLength;
-
   return size;
 }
 


More information about the poppler mailing list