本文整理汇总了Python中httplib.NO_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Python httplib.NO_CONTENT属性的具体用法?Python httplib.NO_CONTENT怎么用?Python httplib.NO_CONTENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类httplib
的用法示例。
在下文中一共展示了httplib.NO_CONTENT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import NO_CONTENT [as 别名]
def send(self, request):
url = self.__get_request_url_for_urllib(request)
msg = request.message
headers = request.headers
try:
u2request = urllib2.Request(url, msg, headers)
self.addcookies(u2request)
self.proxy = self.options.proxy
request.headers.update(u2request.headers)
log.debug('sending:\n%s', request)
fp = self.u2open(u2request, timeout=request.timeout)
self.getcookies(fp, u2request)
headers = fp.headers
if sys.version_info < (3, 0):
headers = headers.dict
reply = Reply(httplib.OK, headers, fp.read())
log.debug('received:\n%s', reply)
return reply
except urllib2.HTTPError as e:
if e.code not in (httplib.ACCEPTED, httplib.NO_CONTENT):
raise TransportError(e.msg, e.code, e.fp)
示例2: _response
# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import NO_CONTENT [as 别名]
def _response(self, step_name, data, size, status_code, error_body):
step_data = [
self.m.json.output({
'status_code': status_code,
'success': status_code in (httplib.OK, httplib.NO_CONTENT),
'size': size,
'error_body': error_body,
}, name='status_json'),
]
if data:
step_data.append(data)
return self.step_data(step_name, *step_data)
示例3: _handle_server_response
# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import NO_CONTENT [as 别名]
def _handle_server_response(self, response):
if response.status in (httplib.OK, httplib.CREATED,
httplib.NO_CONTENT):
return response
logger.debug('invalid response status:{st} body:{body}'.format(
st=response.status, body=response.data))
EtcdError.handle(response)
示例4: _do_request
# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import NO_CONTENT [as 别名]
def _do_request(address, path):
conn = httplib.HTTPConnection(address)
conn.request('GET', path)
res = conn.getresponse()
if res.status in (httplib.OK,
httplib.CREATED,
httplib.ACCEPTED,
httplib.NO_CONTENT):
return res
raise httplib.HTTPException(
res, 'code %d reason %s' % (res.status, res.reason),
res.getheaders(), res.read())
示例5: _handle_delete
# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import NO_CONTENT [as 别名]
def _handle_delete(gcs_stub, filename):
"""Handle DELETE object."""
if gcs_stub.delete_object(filename):
return _FakeUrlFetchResult(httplib.NO_CONTENT, {}, '')
else:
return _FakeUrlFetchResult(httplib.NOT_FOUND, {}, '')