python http OPTIONS請求
通過傳送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
相關文章
- Http協議什麼時候發生options請求?HTTP協議
- python做http請求PythonHTTP
- python-http請求帶AuthorizationPythonHTTP
- python傳送HTTP POST請求PythonHTTP
- http請求HTTP
- HTTP 請求HTTP
- options 請求跨域問題處理跨域
- http請求概述HTTP
- HTTP請求方法HTTP
- http請求頭HTTP
- go http請求GoHTTP
- Python中get、post請求詳解(HTTP請求頭、狀態碼)PythonHTTP
- Python中http請求方法庫彙總PythonHTTP
- 什麼時候會傳送options請求
- 合併HTTP請求vs並行HTTP請求,到底誰更快?HTTP並行
- 合併HTTP請求 vs 並行HTTP請求,到底誰更快?HTTP並行
- Cookie 與 HTTP請求CookieHTTP
- Jsoup http請求JSHTTP
- Android Http請求AndroidHTTP
- HTTP請求報文HTTP
- 使用Python獲取HTTP請求頭資料PythonHTTP
- axios中POST請求變成OPTIONS處理iOS
- 解決 Laravel 接收非簡單請求時,只有收到 OPTIONS 請求的問題Laravel
- 【轉】怎麼用PHP傳送HTTP請求(POST請求、GET請求)?PHPHTTP
- HTTP的請求過程HTTP
- Http請求資料格式HTTP
- HTTP GET請求傳bodyHTTP
- golang 的 http 請求池GolangHTTP
- HTTP 請求與響應HTTP
- Java實現Http請求JavaHTTP
- go http請求流程分析GoHTTP
- 七種HTTP請求方法HTTP
- Http請求體詳解HTTP
- HTTP網路請求原理HTTP
- HTTP請求預設值HTTP
- Http請求相關(轉)HTTP
- 我知道的HTTP請求HTTP
- Http請求與響應HTTP