Curl show only content type

I was wondering if curl can be used to display only the content type of the response header.

I want to check if the content type is text / html, for example, before loading instate to download the file, and then find out what the application is / pdf.

I used the example below in the hope that it will return the document if it is valid for me and the other does nothing or something else! The example below simply prints the full contents of the page.

curl -F "type=text/html" www.google.nl

But if I do something like the example below, it still loads it all, and I don’t think it’s correct ...

curl -F "type=text/html" http://www.axmag.com/download/pdfurl-guide.pdf

Thanks a lot: D

+4
source share
2 answers

-F . HEAD -I.

URL-:

curl -s -I www.google.nl | grep "^ Content-Type:"

-s ​​ .

Accept HTTP-. :

curl -s -H "Accept: text/html" http://www.axmag.com/download/pdfurl-guide.pdf

, - , text/html. , HTML .

+9

"-w" "content-type":

curl -s -o /dev/null -w '%{content_type}' 'google.com'

:

-s: ,

-o: /dev/null

-w: ,

: https://curl.haxx.se/docs/manpage.html

+2

Source: https://habr.com/ru/post/1540679/


All Articles