本文整理汇总了Python中request.Request.init_from_proxy方法的典型用法代码示例。如果您正苦于以下问题:Python Request.init_from_proxy方法的具体用法?Python Request.init_from_proxy怎么用?Python Request.init_from_proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request.Request
的用法示例。
在下文中一共展示了Request.init_from_proxy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_request
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import init_from_proxy [as 别名]
def handle_request(self, msg):
try:
request = Request(self.collection.id)
print request
request.init_from_proxy(msg)
print request.headers
allowed_host = True
allowed_method = True
allowed_status_code = True
if not self.host == '':
if self.host == msg.host:
allowed_host = True
else:
allowed_host = False
if len(self.methods) > 0:
if msg.method in self.methods:
allowed_method = True
else:
allowed_method = False
if allowed_method and allowed_host and allowed_status_code:
print self.rules
if not self.rules['restricted_headers']:
self.remove_restricted_headers(request)
self.collection.add_request(request)
if self.tcp_connection:
self.send_to_postman(request)
print "Sent to Postman"
except Exception as ex:
logging.exception("handle_request: Something awful happened!")
msg.reply()