telnet to port 80

By Hal Canary, 2006-11-30 08:56:31 (link)
#computers-code

To check out http headers, you can use telnet, but I've found it easier to use nc (netcat):

H="en.wikipedia.org"
G="/"
echo -en "GET $G HTTP/1.1\r\nHost: $H\r\n\r\n" \
    | nc $H 80

Here's a script:

#!/bin/sh
#DTPD#
if [ "$#" -ne 2 ] ;  then
  echo -e "useage:\n  $0 HOST RESOURCE"
  echo -e "for example:\n  $0 www.google.com /"
  exit 1
fi
echo -en "GET $2 HTTP/1.1\r\nHost: $1\r\n\r\n"
echo -en "GET $2 HTTP/1.1\r\nHost: $1\r\n\r\n" \
  | nc $1 80

(back)