diff options
author | Brad Peabody <bradpeabody@gmail.com> | 2014-07-12 22:42:06 -0700 |
---|---|---|
committer | Brad Peabody <bradpeabody@gmail.com> | 2014-07-12 22:42:06 -0700 |
commit | 273c25a705c7784ed3fbe15faa11effe05809519 (patch) | |
tree | 53d4a0e1ccce7c141f0d7bf36028a2280aa76f13 /netlib/http.py | |
parent | 4d5d8b65114d061da4f6a41673011ce643c29aab (diff) | |
download | mitmproxy-273c25a705c7784ed3fbe15faa11effe05809519.tar.gz mitmproxy-273c25a705c7784ed3fbe15faa11effe05809519.tar.bz2 mitmproxy-273c25a705c7784ed3fbe15faa11effe05809519.zip |
added option for read_response to only read the headers, beginnings of implementing streamed result in mitmproxy
Diffstat (limited to 'netlib/http.py')
-rw-r--r-- | netlib/http.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/netlib/http.py b/netlib/http.py index f5b8118a..21cde538 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -292,7 +292,7 @@ def parse_response_line(line): return (proto, code, msg) -def read_response(rfile, method, body_size_limit): +def read_response(rfile, method, body_size_limit, include_body=True): """ Return an (httpversion, code, msg, headers, content) tuple. """ @@ -315,8 +315,10 @@ def read_response(rfile, method, body_size_limit): # Parse response body according to http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-16#section-3.3 if method in ["HEAD", "CONNECT"] or (code in [204, 304]) or 100 <= code <= 199: content = "" - else: + elif include_body: content = read_http_body(rfile, headers, body_size_limit, False) + else: + content = None # if include_body==False then a None content means the body should be read separately return httpversion, code, msg, headers, content |