Created
June 15, 2014 02:25
-
-
Save paul-jean/ff56e7598491dcc41b9d to your computer and use it in GitHub Desktop.
awk script to extract header from HTML response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo -e "GET / HTTP/1.0\r\n\r\n" | nc google.com 80 | awk '{a[NR]=$0} END {line=1; while (length(a[line]) > 1) {print a[line]; line += 1} }' |
Author
Author
That's like the hardest way to extract the header from the HTTP response. The easy way is just to issue a HEAD request:
[rule146@rule146: Desktop]$ echo -e "HEAD / HTTP/1.0\r\n\r\n" | nc google.com 80
HTTP/1.0 200 OK
Date: Sun, 15 Jun 2014 02:27:47 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=673824b89046c664:FF=0:TM=1402799267:LM=1402799267:S=VZqMn8MbQeemH-mO; expires=Tue, 14-Jun-2016 02:27:47 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=vhcwH0OamVac7AneZE-WPKPC81oUdcyTZTF78uxDXyBiXcC2-aIj-qV9uCE_FFkQ7Ky6zHOovT_ZedZqBypgT9QMddXm-TzibyRezR08Fb94WuA5PkIO7mXAGK7YJHxr; expires=Mon, 15-Dec-2014 02:27:47 GMT; path=/; domain=.google.com; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: