diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-07-14 17:21:08 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-07-14 17:21:08 +0200 |
commit | c78b426c2a4a1980e145a94b381cb457afeddf65 (patch) | |
tree | 53d4a0e1ccce7c141f0d7bf36028a2280aa76f13 /netlib/http.py | |
parent | 4d5d8b65114d061da4f6a41673011ce643c29aab (diff) | |
parent | 273c25a705c7784ed3fbe15faa11effe05809519 (diff) | |
download | mitmproxy-c78b426c2a4a1980e145a94b381cb457afeddf65.tar.gz mitmproxy-c78b426c2a4a1980e145a94b381cb457afeddf65.tar.bz2 mitmproxy-c78b426c2a4a1980e145a94b381cb457afeddf65.zip |
Merge pull request #40 from bradleypeabody/master
added option for read_response to only read the headers
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 |