|
|
|
@ -771,14 +771,14 @@ class ProxyingHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
|
|
|
|
|
|
|
|
|
index = LPInReleaseIndex(mirror, suite,
|
|
|
|
|
cache=self.server.inrelease_cache)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
inrelease = index.get_inrelease_for_timestamp(
|
|
|
|
|
self.server.snapshot_stamp)
|
|
|
|
|
except LPInReleaseIndexError as e:
|
|
|
|
|
inrelease = None
|
|
|
|
|
|
|
|
|
|
if inrelease is not None:
|
|
|
|
|
if inrelease is None:
|
|
|
|
|
self.__send_error(404, "No InRelease file found for given "
|
|
|
|
|
"mirror, suite and timestamp.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if target == "InRelease":
|
|
|
|
|
# If target is InRelease, send back contents directly.
|
|
|
|
|
data = inrelease.data.encode("utf-8")
|
|
|
|
@ -839,6 +839,12 @@ class ProxyingHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
|
|
|
|
self.end_headers()
|
|
|
|
|
shutil.copyfileobj(response, self.wfile)
|
|
|
|
|
|
|
|
|
|
def __send_error(self, status, message):
|
|
|
|
|
"""Return an HTTP error status and a message in the response body."""
|
|
|
|
|
self.send_response(status)
|
|
|
|
|
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
|
|
|
|
self.wfile.write(message.encode("utf-8"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MagicHTTPProxy(socketserver.ThreadingMixIn, http.server.HTTPServer):
|
|
|
|
|
"""Tiny HTTP server using ProxyingHTTPRequestHandler instances to provide
|
|
|
|
|