I am using curl to download files from the internet and it is working fine. The problem is that I am trying to check if the file exists before downloading it. I was thinking that if the file doesn't exist, then I would receive a CURLcode with and error, but instead of that, I am always receiving CURLE_OK.

Is there a way to check if the file exists with curl? If not, which is the best way to do it in c++?

Thank you in advance.

6 Years
Discussion Span
Last Post by hmartinez

Thank you for your answer.

I tried that at first, but then I needed to parse the 404 error to a string and then search for the error, so some extra code to implement.
I finally realized that I can get the RESPONSE CODE after trying to open the file and I think that's enough for the purpose I had, unless someone thinks that there is a better way to do it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.