mitmproxy/test/test_server.py

48 lines
1.2 KiB
Python
Raw Normal View History

import urllib, urllib2, unittest
2012-06-09 08:41:28 +00:00
import time
import libpathod.test, requests
2011-03-05 22:21:31 +00:00
import tutils
"""
Note that the choice of response code in these tests matters more than you
might think. libcurl treats a 304 response code differently from, say, a
200 response code - it will correctly terminate a 304 response with no
content-length header, whereas it will block forever waiting for content
for a 200 response.
"""
class SanityMixin:
2011-03-05 22:21:31 +00:00
def test_http(self):
assert self.pathod("304").status_code == 304
assert self.log()
2011-03-05 22:21:31 +00:00
def test_large(self):
assert len(self.pathod("200:b@50k").content) == 1024*50
2011-03-05 22:21:31 +00:00
class TestHTTP(tutils.HTTPProxTest, SanityMixin):
pass
class TestHTTPS(tutils.HTTPProxTest, SanityMixin):
ssl = True
class TestReverse(tutils.ReverseProxTest, SanityMixin):
2012-06-09 08:41:28 +00:00
reverse = True
2012-06-14 21:47:04 +00:00
class TestTransparent(tutils.TransparentProxTest, SanityMixin):
transparent = True
class TestProxy(tutils.HTTPProxTest):
2011-03-05 22:21:31 +00:00
def test_http(self):
f = self.pathod("304")
assert f.status_code == 304
2011-03-05 22:21:31 +00:00
l = self.log()
assert l[0].address
assert "host" in l[1].headers
assert l[2].code == 304