http_core.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码
def get_headers(http_response):
  """Retrieves all HTTP headers from an HTTP response from the server.

  This method is provided for backwards compatibility for Python2.2 and 2.3.
  The httplib.HTTPResponse object in 2.2 and 2.3 does not have a getheaders
  method so this function will use getheaders if available, but if not it
  will retrieve a few using getheader.
  """
  if hasattr(http_response, 'getheaders'):
    return http_response.getheaders()
  else:
    headers = []
    for header in (
        'location', 'content-type', 'content-length', 'age', 'allow',
        'cache-control', 'content-location', 'content-encoding', 'date',
        'etag', 'expires', 'last-modified', 'pragma', 'server',
        'set-cookie', 'transfer-encoding', 'vary', 'via', 'warning',
        'www-authenticate', 'gdata-version'):
      value = http_response.getheader(header, None)
      if value is not None:
        headers.append((header, value))
    return headers
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号