当前位置: 首页>>代码示例>>Python>>正文


Python requests.options方法代码示例

本文整理汇总了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",
        ) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:21,代码来源:uptest.py

示例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 
开发者ID:l3uddz,项目名称:plex_autoscan,代码行数:22,代码来源:plex.py

示例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 
开发者ID:l3uddz,项目名称:plex_autoscan,代码行数:25,代码来源:plex.py

示例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 
开发者ID:l3uddz,项目名称:plex_autoscan,代码行数:23,代码来源:plex.py

示例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 
开发者ID:0xdea,项目名称:tactical-exploitation,代码行数:23,代码来源:verbal.py

示例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)#调用写入类 
开发者ID:Ascotbe,项目名称:Medusa,代码行数:22,代码来源:Options.py

示例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) 
开发者ID:vechain,项目名称:web3-gear,代码行数:23,代码来源:cli.py

示例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 
开发者ID:open-craft,项目名称:opencraft,代码行数:8,代码来源:openedx_appserver.py

示例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 
开发者ID:billythekids,项目名称:plugin.video.bimozie,代码行数:12,代码来源:mozie_request.py

示例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) 
开发者ID:flipkart-incubator,项目名称:Astra,代码行数:16,代码来源:sendrequest.py

示例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 
开发者ID:flipkart-incubator,项目名称:Astra,代码行数:13,代码来源:cors.py

示例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 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:7,代码来源:test_webserver.py

示例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')) 
开发者ID:Raz0r,项目名称:aemscan,代码行数:8,代码来源:check_webdav.py

示例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 
开发者ID:kubeflow,项目名称:pipelines,代码行数:6,代码来源:app.py

示例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) 
开发者ID:kalliope-project,项目名称:kalliope,代码行数:6,代码来源:uri.py


注:本文中的requests.options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。