git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@726 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2003-01-05 23:26:07 +00:00
parent 5425aa45da
commit 23e1237a10

20
test/head.py Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/python
"""print headers of an url"""
import httplib, urlparse, sys
def main (url):
parts = urlparse.urlsplit(url)
host = parts[1]
path = urlparse.urlunsplit(('', '', parts[2], parts[3], parts[4]))
h = httplib.HTTPConnection(host)
h.connect()
h.putrequest("HEAD", path, skip_host=1)
h.putheader("Host", host)
h.endheaders()
req = h.getresponse()
print req.msg
if __name__=='__main__':
main(sys.argv[1])