Re: getting http return code
Date: Wed, 6 May 2020 14:15:18 -0600
On 2020-05-06, at 13:00:57, Pierre Brico wrote:
>
> On Wed, May 6, 2020 at 4:08 PM Daniel Stenberg wrote:
>
> ... In most use cases, you'll be fine with something simple
> like this:
>
> code=`curl -w '%{response_code}' -o saved $URL`
>
> I would add that return codes are between 0 (success) and 255.
>
> How do you return HTTP code 404 ?
>
An example that works on Linux:
2028 $ curl -w '%{response_code}\r\n' -o saved https://curl.haxx.se/wombat
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6972 100 6972 0 0 38469 0 --:--:-- --:--:-- --:--:-- 38519
404
2029 $
-- gil
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-05-06