28
28
self.netloc = '%s:%d' % (host, port)
30
def archive_url(self, archive_id, query):
30
def archive_url(self, path, query):
31
31
"""Return the URL for an archive
33
:param archive_id: The id of the archive to generate the URL for.
33
:param oath: The path to generate the URL for.
34
34
:param query: The query to use in the URL, as a dict.
36
path = '/archive/%s' % quote(archive_id)
36
path = '/archive/%s' % quote(path)
37
37
query_string = urlencode(query)
38
38
return urlunparse(('http', self.netloc, path, '', query_string, ''))
40
40
def _get_connection(self):
41
41
return httplib.HTTPConnection(self.host, self.port)
43
def _method_archive(self, method, archive_id, query, body=None):
43
def _method_archive(self, method, path, query, body=None):
44
44
"""Perform an HTTP method on an archive's URL."""
45
url = self.archive_url(archive_id, query)
45
url = self.archive_url(path, query)
46
46
connection = self._get_connection()
47
47
connection.request(method, url, body)
48
48
return connection.getresponse()