I am trying to use netcat
to submit an HTTP GET
request. But it gives me the 505 error.
Does anybody know what is wrong with my use of netcat
?
Thanks.
$ cat main.sh
#!/usr/bin/env bash
netcat -v httpbin.org 80 <<EOF
GET /get HTTP/1.1
EOF
$ ./main.sh
httpbin.org [23.23.171.5] 80 (http) open
HTTP/1.1 505 HTTP Version Not Supported
Connection: close
Server: Cowboy
Date: Fri, 09 Feb 2018 00:26:37 GMT
Content-Length: 0
You must use CRLF line endings, and you must include a Host header.
~$ printf 'GET /get HTTP/1.1\r\nHost:httpbin.org\r\n\r\n' | nc -v httpbin.org 80
HTTP/1.1 200 OK
[…]