curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

getting http return code

From: Jürgen Weber via curl-users <>
Date: Wed, 6 May 2020 15:48:20 +0200


many people want to get the http return code from curl to use it in a
script. There are many complicated solutions that parse out the code
from other curl output. The most daring one I found suggests to add a
second stdout:

I think an easier solution would have to be supported by curl:


if (rc > 100)
   handle HTTP Status code
   handle usual curl return code.

Ok, not nice, and not the Unix way, but it would work, if you get a
http code, everything else was fine.

Another way: add a -w template similar to {stderr} to write to a file

-w '%{file:/tmp/curl-http-rc}' '%{response_code}'

Received on 2020-05-06