Timeline for Getting curl to output HTTP status code?
Current License: CC BY-SA 4.0
21 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 29, 2023 at 16:12 | comment | added | KyleMit♦ |
can also use --head for the more verbose version of -I that does the same thing, but might read more inuitively
|
|
Feb 28, 2023 at 10:00 | comment | added | nir | why this answer was accepted? the -I switch not only interferes with the header sent and method, but it also compromises the ability to receive the response. there is no objective justification to change the header just to see that status code which is received anyway | |
Aug 11, 2022 at 9:07 | comment | added | Juan Alonso | You need to use this solution (-I) if you want to check that a URL is redirecting somewhere else. Without it, you won't get any output. | |
S Oct 9, 2021 at 21:48 | history | suggested | Wouter | CC BY-SA 4.0 |
Improved code formatting
|
Oct 9, 2021 at 16:48 | review | Suggested edits | |||
S Oct 9, 2021 at 21:48 | |||||
Sep 11, 2021 at 3:39 | review | Suggested edits | |||
Sep 12, 2021 at 23:25 | |||||
Apr 29, 2020 at 13:43 | comment | added | Mohamed |
The right way to extract the status number is using -w as in curl -so /dev/null -w 'URL: %{url_effective} at ServerIP: %{remote_ip} and Response: %{response_code}\n' google.com
|
|
Mar 4, 2020 at 22:52 | review | Suggested edits | |||
Mar 5, 2020 at 0:41 | |||||
Jan 4, 2018 at 20:33 | review | Suggested edits | |||
Jan 4, 2018 at 20:42 | |||||
Dec 13, 2017 at 4:12 | comment | added | emeraldhieu | This command shows only some info. I can't see my response. "-i" may be better. | |
Mar 24, 2017 at 22:33 | comment | added | Keith Tyler | Not useful for testing services that return status codes for other methods than GET. Like, REST services. | |
Dec 12, 2016 at 9:39 | comment | added | rhs |
Forwarding stderr to /dev/null is not neccessary if you only want to suppress the progress bar - use -s switch for that.
|
|
Jun 23, 2016 at 10:38 | comment | added | sorin | Here are two working examples, for GET and HEAD -- superuser.com/a/1092635/3004 | |
Jun 23, 2016 at 10:32 | history | edited | sorin | CC BY-SA 3.0 |
added 88 characters in body
|
Nov 30, 2015 at 19:20 | comment | added | jiggy |
curl -I -X GET will send a GET request, but give the same output.
|
|
Sep 21, 2015 at 21:16 | comment | added | Scott McIntyre | Following the redirect after only doing a HEAD request may cause interesting behavior, depending on how the app is programmed. | |
Jul 24, 2014 at 21:16 | comment | added | Aaron Blenkush |
Don't forget to redirect curl's stderr: curl -I http://www.example.org 2>/dev/null | head -n 1 | cut -d$' ' -f2 . Add -L to curl if you need the final status after redirects.
|
|
Jul 17, 2013 at 11:33 | comment | added | Benubird |
And to get just the status number, pipe it to head -n 1|cut -d$' ' -f2
|
|
Sep 6, 2012 at 17:32 | comment | added | Jay Taylor |
NB: curl -I does a HEAD HTTP request, which can be problematic for testing the HTTP status code for some web application servers and services
|
|
Apr 19, 2011 at 15:31 | vote | accept | kdt | ||
Apr 18, 2011 at 10:56 | history | answered | pberlijn | CC BY-SA 3.0 |