diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 16:23:51 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 16:23:51 +1200 |
commit | c335c2b5330865ccab176c6213db63151383a142 (patch) | |
tree | 3dd6029edb0819f906eb91bf580546422d751a2a /libmproxy/protocol | |
parent | ab7e2857cc9095c4cee8ca9b569c16516aa520ba (diff) | |
download | mitmproxy-c335c2b5330865ccab176c6213db63151383a142.tar.gz mitmproxy-c335c2b5330865ccab176c6213db63151383a142.tar.bz2 mitmproxy-c335c2b5330865ccab176c6213db63151383a142.zip |
Add set_cookies method to HTTPResponse
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r-- | libmproxy/protocol/http.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index da8eaa01..eb7749ea 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -918,6 +918,25 @@ class HTTPResponse(HTTPMessage): ret.append([name, [value, attrs]]) return odict.ODict(ret) + def set_cookies(self, odict): + """ + Set the Set-Cookie headers on this response, over-writing existing + headers. + + Accepts an ODict of the same format as that returned by get_cookies. + """ + values = [] + for i in odict.lst: + values.append( + http_cookies.format_set_cookie_header( + i[0], + i[1][0], + i[1][1] + ) + ) + self.headers["Set-Cookie"] = values + + class HTTPFlow(Flow): """ |