mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-18 21:31:00 +00:00
added
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@726 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
5425aa45da
commit
23e1237a10
1 changed files with 20 additions and 0 deletions
20
test/head.py
Normal file
20
test/head.py
Normal 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])
|
||||
Loading…
Reference in a new issue