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


Python Request.init_from_proxy方法代码示例

本文整理汇总了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()
开发者ID:PriyaRaghunatha,项目名称:PostmanProxy,代码行数:39,代码来源:collection_creator_proxy.py


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