本文整理汇总了Python中requests.options方法的典型用法代码示例。如果您正苦于以下问题:Python requests.options方法的具体用法?Python requests.options怎么用?Python requests.options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests
的用法示例。
在下文中一共展示了requests.options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCorsGetAbout
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def testCorsGetAbout(self):
endpoint = helper.getEndpoint()
print("endpoint:", endpoint)
req = endpoint + "/about"
rsp = requests.options(
req,
headers={
"Access-Control-Request-Method": "GET",
"Origin": "*",
"Access-Control-Request-Headers": "Authorization",
},
)
self.assertEqual(rsp.status_code, 200)
# cross origin allowed by default
self.assertEqual(rsp.headers["Access-Control-Allow-Origin"], "*")
self.assertEqual(
rsp.headers["Access-Control-Allow-Methods"], "GET",
)
示例2: split_plex_item
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def split_plex_item(config, metadata_item_id):
try:
url_params = {
'X-Plex-Token': config['PLEX_TOKEN']
}
url_str = '%s/library/metadata/%d/split' % (config['PLEX_LOCAL_URL'], int(metadata_item_id))
# send options request first (webui does this)
requests.options(url_str, params=url_params, timeout=30)
resp = requests.put(url_str, params=url_params, timeout=30)
if resp.status_code == 200:
logger.info("Successfully split 'metadata_item_id': '%d'", int(metadata_item_id))
return True
else:
logger.error("Failed splitting 'metadata_item_id': '%d'... Response =\n%s\n", int(metadata_item_id),
resp.text)
except Exception:
logger.exception("Exception splitting 'metadata_item' %d: ", int(metadata_item_id))
return False
示例3: match_plex_item
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def match_plex_item(config, metadata_item_id, new_guid, new_name):
try:
url_params = {
'X-Plex-Token': config['PLEX_TOKEN'],
'guid': new_guid,
'name': new_name,
}
url_str = '%s/library/metadata/%d/match' % (config['PLEX_LOCAL_URL'], int(metadata_item_id))
requests.options(url_str, params=url_params, timeout=30)
resp = requests.put(url_str, params=url_params, timeout=30)
if resp.status_code == 200:
logger.info("Successfully matched 'metadata_item_id' '%d' to '%s' (%s).", int(metadata_item_id), new_name,
new_guid)
return True
else:
logger.error("Failed matching 'metadata_item_id' '%d' to '%s': %s... Response =\n%s\n",
int(metadata_item_id),
new_name, new_guid, resp.text)
except Exception:
logger.exception("Exception matching 'metadata_item' %d: ", int(metadata_item_id))
return False
示例4: refresh_plex_item
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def refresh_plex_item(config, metadata_item_id, new_name):
try:
url_params = {
'X-Plex-Token': config['PLEX_TOKEN'],
}
url_str = '%s/library/metadata/%d/refresh' % (config['PLEX_LOCAL_URL'], int(metadata_item_id))
requests.options(url_str, params=url_params, timeout=30)
resp = requests.put(url_str, params=url_params, timeout=30)
if resp.status_code == 200:
logger.info("Successfully refreshed 'metadata_item_id' '%d' of '%s'.", int(metadata_item_id),
new_name)
return True
else:
logger.error("Failed refreshing 'metadata_item_id' '%d' of '%s': Response =\n%s\n",
int(metadata_item_id),
new_name, resp.text)
except Exception:
logger.exception("Exception refreshing 'metadata_item' %d: ", int(metadata_item_id))
return False
示例5: scan_options
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def scan_options(url, timeout):
"""
OPTIONS method scanner
"""
try:
r = requests.options(
url=url,
timeout=timeout,
verify=False)
print(
" OPTIONS" + "\t> "
+ str(r.status_code) + " ("
+ str(requests.status_codes._codes[r.status_code][0]) + ")")
print(" " + "Methods: " + r.headers["allow"])
except (KeyboardInterrupt, SystemExit):
sys.exit(1)
except Exception as err:
pass # ignore errors
示例6: medusa
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def medusa(Url:str,RandomAgent:str,proxies:str=None,**kwargs)->None:
proxies=Proxies().result(proxies)
scheme, url, port = UrlProcessing().result(Url)
try:
payload_url = Url
headers = {
'User-Agent': RandomAgent,
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate",
}
resp = requests.options(payload_url,headers=headers,proxies=proxies, timeout=5, verify=False)
if r"OPTIONS" in resp.headers.get('Allow'):
Medusa = "{}存在Options方法开启漏洞\r\n验证数据:\r\n漏洞位置:{}\r\n漏洞详情:{}\r\n".format(url,payload_url,resp.headers)
_t = VulnerabilityInfo(Medusa)
VulnerabilityDetails(_t.info, url,**kwargs).Write() # 传入url和扫描到的数据
WriteFile().result(str(url),str(Medusa))#写入文件,url为目标文件名统一传入,Medusa为结果
except Exception as e:
_ = VulnerabilityInfo('').info.get('algroup')
ErrorHandling().Outlier(e, _)
_l = ErrorLog().Write("Plugin Name:"+_+" || Target Url:"+url,e)#调用写入类
示例7: run_server
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def run_server(host, port, endpoint, keystore, passcode, log, debug):
try:
response = requests.options(endpoint)
response.raise_for_status()
except requests.exceptions.ConnectionError:
print("Unable to connect to Thor-Restful server.")
return
print(make_version())
print("Listening on %s:%s" % (host, port))
thor.set_endpoint(endpoint)
if keystore == "":
thor.set_accounts(solo())
else:
thor.set_accounts(_keystore(keystore, passcode))
app = web.Application()
app.router.add_post("/", lambda r: handle(r, log, debug))
app.router.add_options("/", lambda r: web.Response(headers=res_headers))
web.run_app(app, host=host, port=port)
示例8: heartbeat_active
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def heartbeat_active(self):
"""Is this server's /heartbeat running ok (returning code < 400)"""
try:
return requests.options('http://{}/heartbeat'.format(self.server.public_ip)).ok
except requests.exceptions.ConnectionError:
return False
示例9: options
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def options(self, url, params=None, headers=None, redirect=True, cookies=None, verify=True):
# if headers:
# headers = self.DEFAULT_HEADERS.update(headers)
if self.session:
self.r = self.session.options(url, headers=headers, timeout=self.TIMEOUT, params=params,
allow_redirects=redirect, verify=verify)
else:
self.r = requests.options(url, headers=headers, timeout=self.TIMEOUT, params=params,
allow_redirects=redirect)
return self.r
示例10: api_request
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def api_request(url,method,headers,body=None):
try:
if method.upper() == "GET":
auth_request = requests.get(url,headers=headers, allow_redirects=False,verify=False)
elif method.upper() == "POST":
auth_request = requests.post(url,headers=headers,json=body, allow_redirects=False,verify=False)
elif method.upper() == "PUT":
auth_request = requests.put(url,headers=headers,data=body, allow_redirects=False,verify=False)
elif method.upper() == "OPTIONS":
auth_request = requests.options(url,headers=headers, verify=False)
return auth_request
except Exception as e:
logs.logging.error("Exception from sendrequest %s",e)
示例11: check_custom_header
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def check_custom_header(url, header_name):
# Check if custom header is allowed to send.
request_header = {'Access-Control-Request-Headers' : header_name}
req_custom_header = requests.options(url, header_name,verify=False)
try:
if req_custom_header.headers['Access-Control-Allow-Headers'] == header_name:
return True
else:
return False
except:
return False
示例12: test_options
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def test_options(self, circuits_app, new_incident):
"""Verify the web service is responding to the OPTIONS method"""
#WebTest({}).register(circuits_app.app.component_loader)
response = requests.options(SERVICE_URL)
assert response.status_code == 200
示例13: run
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def run(url):
response = requests.options(url + '/')
if 'propfind' in response.headers.get('allow', '').lower() or response.status_code == 401:
click.echo(click.style('WebDAV is enabled', fg='green'))
else:
click.echo(click.style('WebDAV is disabled', fg='red'))
示例14: is_deployment_available
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def is_deployment_available(params):
url = get_deployment_url(params)
response = requests.options(url)
return response.status_code == 200
示例15: do_options
# 需要导入模块: import requests [as 别名]
# 或者: from requests import options [as 别名]
def do_options(self):
logger.debug(self.neuron_name + " do_options method called")
r = requests.options(url=self.url, **self.parameters)
self.post_processing_request(r)