diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-04-03 10:16:39 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-04-03 10:16:39 +0200 |
commit | f5fe93bf1317fef0039e5b74e6c0812c78942db8 (patch) | |
tree | a58423514fd1759580ab89f4ddb6b795bbc3a461 /test/netlib/http/test_response.py | |
parent | 16fdbb4f2fcee8f1db4a516d173ec2881161b3ea (diff) | |
parent | 4e2acc4d9d453126ac0e8aa20f3cb7dcc6a85a8c (diff) | |
download | mitmproxy-f5fe93bf1317fef0039e5b74e6c0812c78942db8.tar.gz mitmproxy-f5fe93bf1317fef0039e5b74e6c0812c78942db8.tar.bz2 mitmproxy-f5fe93bf1317fef0039e5b74e6c0812c78942db8.zip |
Merge pull request #1074 from mitmproxy/move-response-refresh
move HTTPResponse.refresh into netlib
Diffstat (limited to 'test/netlib/http/test_response.py')
-rw-r--r-- | test/netlib/http/test_response.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index 14588000..a0c44d90 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -1,6 +1,9 @@ from __future__ import absolute_import, print_function, division +import email + import six +import time from netlib.http import Headers from netlib.odict import ODict, ODictCaseless @@ -100,3 +103,23 @@ class TestResponseUtils(object): v = resp.cookies assert len(v) == 1 assert v["foo"] == [["bar", ODictCaseless()]] + + def test_refresh(self): + r = tresp() + n = time.time() + r.headers["date"] = email.utils.formatdate(n) + pre = r.headers["date"] + r.refresh(n) + assert pre == r.headers["date"] + r.refresh(n + 60) + + d = email.utils.parsedate_tz(r.headers["date"]) + d = email.utils.mktime_tz(d) + # Weird that this is not exact... + assert abs(60 - (d - n)) <= 1 + + cookie = "MOO=BAR; Expires=Tue, 08-Mar-2011 00:20:38 GMT; Path=foo.com; Secure" + r.headers["set-cookie"] = cookie + r.refresh() + # Cookie refreshing is tested in test_cookies, we just make sure that it's triggered here. + assert cookie != r.headers["set-cookie"] |