Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

301 curl does not show without -v

I was looking at the 301s that several 2.level domains use to redirect to their www 3.level domain, and I thought curl on its own was enough, for example

curl  myvote.io
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.myvote.io/">here</A>.
</BODY></HTML>

However, I had to use curl -v to get any output on another domain :

curl -v evitaochel.com
* Rebuilt URL to: evitaochel.com/
* Hostname was NOT found in DNS cache
*   Trying 62.116.130.8...
* Connected to evitaochel.com (62.116.130.8) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: evitaochel.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Mon, 13 Oct 2014 16:18:02 GMT
* Server Apache is not blacklisted
< Server: Apache
< Location: http://www.evitaochel.com
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8 
<
* Connection #0 to host evitaochel.com left intact

If anything, I was expecting myvote.io to be the weirder one,

curl -v myvore.io
* Rebuilt URL to: myvote.io/
* Hostname was NOT found in DNS cache
*   Trying 216.239.36.21...
* Connected to myvote.io (216.239.36.21) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: myvote.io
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.myvote.io/
< Date: Mon, 13 Oct 2014 16:30:40 GMT
< Content-Type: text/html; charset=UTF-8
* Server ghs is not blacklisted
< Server: ghs
< Content-Length: 218
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Alternate-Protocol: 80:quic,p=0.01
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.myvote.io/">here</A>.
</BODY></HTML>
* Connection #0 to host myvote.io left intact

shows that it includes some extensions and is served by ghs, Google I guess. Any ideas what could be the cause, and if the cause is always visible in "curl -v" or could be some hidden configuration?

like image 243
fidetrainerNET Avatar asked Oct 13 '14 16:10

fidetrainerNET


People also ask

Does Curl work on HTTP?

cURL supports several different protocols, including HTTP and HTTPS, and runs on almost every platform.

How do you send a POST request on curl?

You can send a POST request with Curl by explicitly specifying the POST method with the -X POST command line parameter or passing data to Curl using the -d or --data command line parameter.


1 Answers

curl doesn't show any response headers when used without any option, that's just how it works. Use -v or even -i to get to see the headers only.

A redirect page (301, 302 or whatever) MAY contain a body but it also MAY NOT. That is up to the site.

Since you get HTTP redirects, you may want to use -L too to make curl follow them.

like image 71
Daniel Stenberg Avatar answered Feb 07 '23 00:02

Daniel Stenberg