użycie curl do uzyskania nagłówka
Dlaczego to nie działa:
curl -X HEAD http://www.google.com
Ale oba działają dobrze:
curl -I http://www.google.com
curl -X GET http://www.google.com
35
3 answers
Musisz dodać flagę-i do pierwszego polecenia, aby włączyć nagłówek HTTP w wyjściu. Jest to wymagane do drukowania nagłówków.
curl -X HEAD -i http://www.google.com
Więcej tutaj: https://serverfault.com/questions/140149/difference-between-curl-i-and-curl-x-head
68
Author: dmc7z,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-13 12:13:44
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-13 12:13:44
curl --head https://www.example.net
Wskazywał mnie na to sam curl; kiedy wydałem komendę z -X HEAD
, wypisał:
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
21
Author: bovender,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-28 10:03:45
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-28 10:03:45
Google.com nie odpowiada na HTTP HEAD
żądania, dlatego widzisz hang za pierwszą komendę.
Odpowiada na żądania GET
, dlatego działa trzecie polecenie.
Jeśli chodzi o drugi, curl wypisuje nagłówki ze standardowego żądania.
1
Author: SheetJS,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-16 04:02:15
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-16 04:02:15