def get_headers(self): headers = CaseInsensitiveDict() headers['Cache-Control'] = 'max-age={0}'.format(self.cache_control) if self.content_encoding is not None: headers['Content-Encoding'] = self.content_encoding headers.update(self.extra_headers) return headers
def __init__(self, status, reason=None, headers=None, body=''): if reason is None: reason = http_client.responses[status] if headers is None: headers = {} self.status = status self.reason = reason self.headers = CaseInsensitiveDict(headers) self.body = body
def get_headers(self): headers = CaseInsensitiveDict() for k in ("Cache-Control", "X-TTL"): headers[k] = 'max-age={0}'.format(self.cache_control) if self.content_encoding is not None: headers['Content-Encoding'] = self.content_encoding return headers
def getURLHeaders(url): url = urllib.parse.urlparse(url) conn = http_client.HTTPConnection(url.netloc) conn.request('HEAD', urllib.parse.quote(url.path)) response = conn.getresponse() return CaseInsensitiveDict(response.getheaders())
def __init__(self, connection, method, url, body, headers): self.connection = connection self.method = method self.url = url self.body = body self.headers = CaseInsensitiveDict(headers) u = urllib.parse.urlparse(url) self.path = u.path self.params = urllib.parse.parse_qs(u.query, keep_blank_values=True)
class TestHTTPResponse(object): def __init__(self, status, reason=None, headers=None, body=''): if reason is None: reason = http_client.responses[status] if headers is None: headers = {} self.status = status self.reason = reason self.headers = CaseInsensitiveDict(headers) self.body = body def getheader(self, header, default=None): return self.headers.get(header, default) def getheaders(self): return self.headers def read(self): return self.body
def __init__(self, engine, path): super(S3File, self).__init__(engine, path) self.extra_headers = CaseInsensitiveDict()