GET COMMAND in HTTP Request

I cannot use GET command to get the web site body content only. For example:

[root@mrtg home]# echo -e "GET / HTTP/\r\nHost: test.com:80\r\n\r\n" | nc 192.168.1.201 80
HTTP/1.1 200 OK
Date: Sun, 20 Mar 2016 13:45:49 GMT
Server: Apache/2.2.15 (CentOS)
Last-Modified: Sun, 20 Mar 2016 10:28:08 GMT
ETag: "6068a-10-52e786faf8f79"
Accept-Ranges: bytes
Content-Length: 16
Connection: close
Content-Type: text/html; charset=UTF-8

test.com-server
[root@mrtg home]#

If I use this command echo -e "GET / /\r\nHost: test.com:80\r\n\r\n" | nc 192.168.1.201 80

I can get the default host body content only. I have 3 x Virtualhost in my Apache2.4 server.

Please advise.

Answer

The GET command is

GET / HTTP/1.1
Host: test.com

The HTTP/1.1 is essential in order to specify the Host.

However, you should use wget or curl which are programs written for the purpose.

Attribution
Source : Link , Question Author : tomli , Answer Author : Law29

Leave a Comment