发布时间:2019-09-01 11:00:22编辑:auto阅读(1802)
通过发送http OPTIONS请求,可以获取 http允许的方法(我这里主要测试网站是否开启webDav),测试如下:
import urllib2
import json
import httplib
url='192.168.149.131'
def http_get():
conn = httplib.HTTPConnection(url)
conn.request("GET", "/iisstart.htm")
ret = conn.getresponse()
response = ret.read()
return response
def http_options():
conn = httplib.HTTPConnection(url)
conn.request("OPTIONS", "/")
ret = conn.getresponse()
print ret.msg.dict
print ret.msg.dict['allow']
ret = http_options()
#ret2 = http_get()
#print ret
E:\>python isWebDav.py
{'content-length': '0', 'accept-ranges': 'none', 'ms-author-via': 'DAV', 'server': 'Microsoft-IIS/6.0', 'dav': '1, 2', 'dasl': '<DAV:sql>', 'allow': 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK', 'cache-control': 'private', 'date': 'Wed, 29 Mar 2017 15:59:20 GMT', 'public': 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH'}
OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK
上一篇: python安装pytorch方法
下一篇: python实现屏幕截图
47868
46434
37321
34767
29337
25999
24952
19970
19568
18056
5811°
6436°
5953°
5979°
7083°
5929°
5970°
6462°
6426°
7804°