2012-10-14 77 views
3

我想用HTTP OPTIONS方法允許的HTTP方法,如:顯示允許的HTTP方法

telnet site.com 80 
OPTIONS/HTTP/1.0 

結果:

HTTP/1.1 200 OK 
Date: Sun, 14 Oct 2012 21:04:39 GMT 
Server: Apache 
Allow: GET,HEAD,POST,OPTIONS 
Content-Length: 0 
Connection: close 
Content-Type: text/html 

我怎麼可以這樣使用Python庫?

回答

2
import httplib 
conn = httplib.HTTPConnection('w3.com') 
conn.request('OPTIONS', '/') 
response = conn.getresponse() 
print response.getheader('allow') 

結果是

OPTIONS, TRACE, GET, HEAD, POST 
+1

THX,但我可以做它的urllib2? –