cURL / Mailing Lists / curl-library / Single Mail

curl-library

BUG? CONTENT_LENGTH for 'file' scheme without actually reading the file does not work

From: Hidemoto Nakada <hide-nakada_at_aist.go.jp>
Date: Tue, 3 Feb 2009 22:20:48 +0100

Hello,

I want to have code to get content-length without actually reading the data.
the code below works fine for 'http' scheme but does not for 'file' scheme.

------------------
  curl_easy_setopt(dwHandle, CURLOPT_URL, url);
  curl_easy_setopt(dwHandle, CURLOPT_HEADER, 1);
  curl_easy_setopt(dwHandle, CURLOPT_NOBODY, 1);
  curl_easy_setopt(dwHandle, CURLOPT_WRITEFUNCTION, &nullOut);

  curl_easy_perform(dwHandle);
  curl_easy_getinfo(dwHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &dSize);
------------------
it always returns 0 for file.

I have take a look into the code and found that no code
to set the progress.size_dl exists in the code path for NOBODY and HEADER.

I added two lines of code as attached patch, and it looks like works fine.

Is this a bug, or am i missing something?

-- 
  HIDEMOTO NAKADA, Ph.D, AIST, Japan
*** file.c	2009-02-03 22:16:06.000000000 +0100
--- file.old.c	2009-02-03 22:15:33.000000000 +0100
***************
*** 496,503 ****
                 tm->tm_sec);
        result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
      }
-     if(fstated)
-       Curl_pgrsSetDownloadSize(data, expected_size);
      return result;
    }
--- 496,501 ----
Received on 2009-02-03