diff options
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r-- | libmproxy/proxy.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index e3eace3b..631e2470 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -124,6 +124,7 @@ def parse_request_line(request): class Request(controller.Msg): FMT = '%s %s HTTP/1.1\r\n%s\r\n%s' + FMT_PROXY = '%s %s://%s:%s%s HTTP/1.1\r\n%s\r\n%s' def __init__(self, client_conn, host, port, scheme, method, path, headers, content, timestamp=None): self.client_conn = client_conn self.host, self.port, self.scheme = host, port, scheme @@ -132,6 +133,9 @@ class Request(controller.Msg): self.close = False controller.Msg.__init__(self) + def is_cached(self): + return False + def get_state(self): return dict( host = self.host, @@ -189,7 +193,10 @@ class Request(controller.Msg): def short(self): return "%s %s"%(self.method, self.url()) - def assemble(self): + def assemble_proxy(self): + return self.assemble(True) + + def assemble(self, _proxy = False): """ Assembles the request for transmission to the server. We make some modifications to make sure interception works properly. @@ -210,8 +217,10 @@ class Request(controller.Msg): content = "" if self.close: headers["connection"] = ["close"] - data = (self.method, self.path, str(headers), content) - return self.FMT%data + if not _proxy: + return self.FMT % (self.method, self.path, str(headers), content) + else: + return self.FMT_PROXY % (self.method, self.scheme, self.host, self.port, self.path, str(headers), content) class Response(controller.Msg): @@ -221,6 +230,7 @@ class Response(controller.Msg): self.code, self.msg = code, msg self.headers, self.content = headers, content self.timestamp = timestamp or time.time() + self.cached = False controller.Msg.__init__(self) def get_state(self): @@ -256,6 +266,9 @@ class Response(controller.Msg): def is_response(self): return True + def is_cached(self): + return self.cached + def short(self): return "%s %s"%(self.code, self.msg) |