diff options
author | Maximilian Hils <git@maximilianhils.com> | 2013-12-15 06:33:18 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2013-12-15 06:33:18 +0100 |
commit | f4b58ba495f5faefbfdd85ae15532cf36e2f74c9 (patch) | |
tree | 5abfc08d8da5223ede45fb2c0745b2d1fbcb2c6e /libmproxy | |
parent | 6ec2e6f24f2e64854e80d81c04ae44c094486821 (diff) | |
download | mitmproxy-f4b58ba495f5faefbfdd85ae15532cf36e2f74c9.tar.gz mitmproxy-f4b58ba495f5faefbfdd85ae15532cf36e2f74c9.tar.bz2 mitmproxy-f4b58ba495f5faefbfdd85ae15532cf36e2f74c9.zip |
move CONTINUE checks into mitmproxy
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/proxy.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 3098aff4..cb931d10 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -415,8 +415,9 @@ class ProxyHandler(tcp.BaseHandler): raise ProxyError(400, "Bad HTTP request line: %s"%repr(line)) method, scheme, host, port, path, httpversion = r headers = self.read_headers(authenticate=True) - content = http.read_http_body_request( - self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit + self.handle_expect_header(headers, httpversion) + content = http.read_http_body( + self.rfile, headers, self.config.body_size_limit, True ) return flow.Request( client_conn, httpversion, host, port, scheme, method, path, headers, content, @@ -446,14 +447,23 @@ class ProxyHandler(tcp.BaseHandler): raise ProxyError(400, "Bad HTTP request line: %s"%repr(line)) method, path, httpversion = r headers = self.read_headers(authenticate=False) - content = http.read_http_body_request( - self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit + self.handle_expect_header(headers, httpversion) + content = http.read_http_body( + self.rfile, headers, self.config.body_size_limit, True ) return flow.Request( client_conn, httpversion, host, port, scheme, method, path, headers, content, self.rfile.first_byte_timestamp, utils.timestamp() ) + def handle_expect_header(self, headers, httpversion): + if "expect" in headers: + if "100-continue" in headers['expect'] and httpversion >= (1, 1): + #FIXME: Check if content-length is over limit + self.wfile.write('HTTP/1.1 100 Continue\r\n' + '\r\n') + del headers['expect'] + def read_headers(self, authenticate=False): headers = http.read_headers(self.rfile) if headers is None: |