cURL / Mailing Lists / curl-library / Single Mail


How to detect missing Content-Length response header?

From: James Cheng <>
Date: Thu, 19 Feb 2009 12:06:06 -0800


I'm using curl_easy_getinfo() with CURLINFO_CONTENT_LENGTH_DOWNLOAD in order to get the value of Content-Length. If the Content-Length header was not present in the response headers at all, curl still returns "0" with curl_easy_getinfo() returning CURLE_OK. That means there's no built-in way to detect Content-Length actually being 0, vs the Content-Length header not being sent.

Is there some other mechanism? If not, it looks like I'll have to check for the headers as they come in, using the HEADERFUNCTION callback.

Received on 2009-02-19