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


Python Headers.iteritems方法代码示例

本文整理汇总了Python中twisted.web.http_headers.Headers.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python Headers.iteritems方法的具体用法?Python Headers.iteritems怎么用?Python Headers.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.http_headers.Headers的用法示例。


在下文中一共展示了Headers.iteritems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeRequest

# 需要导入模块: from twisted.web.http_headers import Headers [as 别名]
# 或者: from twisted.web.http_headers.Headers import iteritems [as 别名]
 def makeRequest(self, bucket, key, method, action=None, params=None,
                 body=None, headers=None, processResponse=True,
                 responseContentType=None):
     uri = self._uri(bucket, key, action, params)
     if not headers:
         headers = {}
     if body and 'Content-Type' not in headers:
         headers['Content-Type'] = getattr(body, 'contentType', None)
     if hasattr(body, 'md5Hash') and 'Content-MD5' not in headers:
         headers['Content-MD5'] = body.md5Hash()
     headers = Headers({k: [v] for k, v in headers.iteritems()
                        if k and v is not None})
     d = self._agent.request(method, uri, headers, body)
     if processResponse:
         d.addCallback(self.processResponse, responseContentType)
     return d
开发者ID:GaretJax,项目名称:txs3,代码行数:18,代码来源:client.py

示例2: send_request

# 需要导入模块: from twisted.web.http_headers import Headers [as 别名]
# 或者: from twisted.web.http_headers.Headers import iteritems [as 别名]
	def send_request(self, method, url, headers, body):
		"""
		Send the request.

		.. NOTE:: This should not be called directly. Use *self.request()*.

		*method* (``str``) is the HTTP request method.

		*url* (``str``) is the URL of the request.

		*headers* (``dict``) are any headers to send. This can be ``None``.

		*body* (``str`` or ``file``) is the body of the request. This can be
		``None``.

		Returns a deferred (``twisted.internet.defer.Deferred``) which is
		fired with the response (``twisted.web.iweb.IResponse``) once all
		response headers have been received.
		"""
		body_is_file = callable(getattr(body, 'read', None))
		headers = Headers({key: [val] for key, val in headers.iteritems()}) if headers else None
		#producer = FileBodyProducer(body if body_is_file else StringIO(body)) if body is not None else None
		producer = XXXStringProducer(body.read() if body_is_file else body) if body is not None else None
		return self.tx_agent.request(method, url, headers=headers, bodyProducer=producer)
开发者ID:JDBurnZ,项目名称:python-amazon-mws,代码行数:26,代码来源:twisted.py


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