def test_200_14(self): conf = HttpdConf() conf.add_line(""" LimitRequestFields 20 """) conf.add_vhost_cgi() conf.install() assert TestEnv.apache_restart() == 0 url = TestEnv.mkurl("https", "cgi", "/") opt = [] for i in range(21): opt += ["-H", "x{0}: 1".format(i)] r = TestEnv.curl_get(url, options=opt) assert 431 == r["response"]["status"] conf = HttpdConf() conf.add_line(""" LimitRequestFields 0 """) conf.add_vhost_cgi() conf.install() assert TestEnv.apache_restart() == 0 url = TestEnv.mkurl("https", "cgi", "/") opt = [] for i in range(100): opt += ["-H", "x{0}: 1".format(i)] r = TestEnv.curl_get(url, options=opt) assert 200 == r["response"]["status"]
def test_100_01(self): # this host defaults to h2, but we can request h1 url = TestEnv.mkurl("https", "cgi", "/hello.py") assert "2" == TestEnv.curl_protocol_version( url ) assert "1.1" == TestEnv.curl_protocol_version( url, options=[ "--http1.1" ] ) # this host does not enable h2, it always falls back to h1 url = TestEnv.mkurl("https", "noh2", "/hello.py") assert "1.1" == TestEnv.curl_protocol_version( url ) assert "1.1" == TestEnv.curl_protocol_version( url, options=[ "--http2" ] )
def test_100_01(self): # this host defaults to h2, but we can request h1 url = TestEnv.mkurl("https", "cgi", "/hello.py") assert "2" == TestEnv.curl_protocol_version(url) assert "1.1" == TestEnv.curl_protocol_version(url, options=["--http1.1"]) # this host does not enable h2, it always falls back to h1 url = TestEnv.mkurl("https", "noh2", "/hello.py") assert "1.1" == TestEnv.curl_protocol_version(url) assert "1.1" == TestEnv.curl_protocol_version(url, options=["--http2"])
def test_003_02(self): with open(TestEnv.e2e_src( "htdocs/test1/index.html"), mode='rb') as file: src = file.read() url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert src == r["response"]["body"] url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5, [ "--http1.1" ]) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["protocol"] assert src == r["response"]["body"]
def test_003_02(self): with open(TestEnv.e2e_src( "htdocs/test1/index.html"), mode='rb') as file: src = file.read() url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert src == r["response"]["body"] url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5, [ "--http1.1" ]) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["protocol"] assert src == r["response"]["body"]
def test_003_21(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5, [ "-I" ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] s = self.clean_header(r["response"]["body"]) assert '''HTTP/2 200 content-length: 2007 content-type: text/html ''' == s r = TestEnv.curl_get(url, 5, [ "-I", url ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] s = self.clean_header(r["response"]["body"]) assert '''HTTP/2 200 content-length: 2007 content-type: text/html HTTP/2 200 content-length: 2007 content-type: text/html ''' == s
def test_002_02(self): url = TestEnv.mkurl("https", "test1", "/alive.json") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert True == r["response"]["json"]["alive"] assert "test1" == r["response"]["json"]["host"] assert "application/json" == r["response"]["header"]["content-type"]
def test_200_03(self): url = TestEnv.mkurl("https", "cgi", "/hecho.py") for hex in [ "10", "7f" ]: r = TestEnv.curl_post_data(url, "name=x%%%s&value=yz" % hex) assert 0 != r["rv"] r = TestEnv.curl_post_data(url, "name=x&value=y%%%sz" % hex) assert 0 != r["rv"]
def test_103_06(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, options=[ "--http1.1" ]) assert 0 == r["rv"] assert "response" in r assert "upgrade" in r["response"]["header"] assert "h2" == r["response"]["header"]["upgrade"]
def test_104_04(self): url = TestEnv.mkurl("https", "pad2", "/echo.py") for data in [ "x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx" ]: r = r = TestEnv.nghttp().post_data(url, data, 5) assert 200 == r["response"]["status"] for i in r["paddings"]: assert i in range(0, 4)
def test_400_07(self): url = TestEnv.mkurl("https", "push", "/006-push7.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert '/006/006.css' == promises[0]["request"]["header"][":path"]
def test_002_02(self): url = TestEnv.mkurl("https", "test1", "/alive.json") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert True == r["response"]["json"]["alive"] assert "test1" == r["response"]["json"]["host"] assert "application/json" == r["response"]["header"]["content-type"]
def test_003_21(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, 5, [ "-I" ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] s = self.clean_header(r["response"]["body"]) assert '''HTTP/2 200 content-length: 2007 content-type: text/html ''' == s r = TestEnv.curl_get(url, 5, [ "-I", url ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] s = self.clean_header(r["response"]["body"]) assert '''HTTP/2 200 content-length: 2007 content-type: text/html HTTP/2 200 content-length: 2007 content-type: text/html ''' == s
def test_101_04(self): url = TestEnv.mkurl("https", "ssl", "/ssl-client-verify/index.html") r = TestEnv.curl_get(url, options=["-vvv", "--tlsv1.2", "--tls-max", "1.2"]) assert 0 != r["rv"] assert not "response" in r assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
def test_002_01(self): url = TestEnv.mkurl("http", "test1", "/alive.json") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["protocol"] assert True == r["response"]["json"]["alive"] assert "test1" == r["response"]["json"]["host"]
def test_101_01(self): url = TestEnv.mkurl("https", "ssl", "/renegotiate/cipher/") r = TestEnv.curl_get( url, options=["-v", "--http1.1", "--tlsv1.2", "--tls-max", "1.2"]) assert 0 == r["rv"] assert "response" in r assert 403 == r["response"]["status"]
def test_101_02(self): url = TestEnv.mkurl("https", "ssl", "/renegotiate/cipher/") r = TestEnv.curl_get(url, options=["-vvv", "--tlsv1.2", "--tls-max", "1.2"]) assert 0 != r["rv"] assert not "response" in r assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r["out"]["err"])
def test_103_01(self): url = TestEnv.mkurl("http", "test1", "/index.html") r = TestEnv.curl_get(url) assert 0 == r["rv"] assert "response" in r assert "upgrade" in r["response"]["header"] assert "h2c" == r["response"]["header"]["upgrade"]
def test_103_06(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_get(url, options=[ "--http1.1" ]) assert 0 == r["rv"] assert "response" in r assert "upgrade" in r["response"]["header"] assert "h2" == r["response"]["header"]["upgrade"]
def test_200_03(self): url = TestEnv.mkurl("https", "cgi", "/hecho.py") for hex in ["10", "7f"]: r = TestEnv.curl_post_data(url, "name=x%%%s&value=yz" % hex) assert 0 != r["rv"] r = TestEnv.curl_post_data(url, "name=x&value=y%%%sz" % hex) assert 0 != r["rv"]
def test_200_11(self): url = TestEnv.mkurl("https", "cgi", "/") val = "1234567890" # 10 chars for i in range(3): # make a 10000 char string val = "%s%s%s%s%s%s%s%s%s%s" % (val, val, val, val, val, val, val, val, val, val) # LimitRequestFieldSize 8190 ok, one more char -> 400 in HTTP/1.1 # (we send 4000+4185 since they are concatenated by ", " and start with "x: " r = TestEnv.curl_get(url, options=[ "-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4185]) ]) assert 200 == r["response"]["status"] r = TestEnv.curl_get(url, options=[ "--http1.1", "-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4189]) ]) assert 400 == r["response"]["status"] r = TestEnv.curl_get(url, options=[ "-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4191]) ]) assert 431 == r["response"]["status"]
def test_400_07(self): url = TestEnv.mkurl("https", "push", "/006-push7.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert '/006/006.css' == promises[0]["request"]["header"][":path"]
def test_400_32(self): url = TestEnv.mkurl("https", "hints", "/006-nohints.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert not "previous" in r["response"]
def test_400_32(self): url = TestEnv.mkurl("https", "hints", "/006-nohints.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert not "previous" in r["response"]
def test_400_53(self): url = TestEnv.mkurl("https", "push", "/006-push.html") r = TestEnv.nghttp().get( url, options=['-H', 'accept-push-policy: fast-load']) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises)
def test_100_02(self): url = TestEnv.mkurl("https", "cgi", "/hello.py") hostname = ("cgi-alias.%s" % TestEnv.HTTP_TLD) r = TestEnv.curl_get(url, 5, ["-H", "Host:%s" % hostname]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert hostname == r["response"]["json"]["host"]
def test_300_03(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_post_data(url, 'XYZ', options=["-H", "expect: the-unexpected"]) assert 417 == r["response"]["status"] assert not "previous" in r["response"]
def test_100_03(self): url = TestEnv.mkurl("https", "cgi", "/") hostname = ("test1.%s" % TestEnv.HTTP_TLD) r = TestEnv.curl_get(url, 5, ["-H", "Host:%s" % hostname]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert "text/html" == r["response"]["header"]["content-type"]
def test_103_01(self): url = TestEnv.mkurl("http", "test1", "/index.html") r = TestEnv.curl_get(url) assert 0 == r["rv"] assert "response" in r assert "upgrade" in r["response"]["header"] assert "h2c" == r["response"]["header"]["upgrade"]
def test_002_01(self): url = TestEnv.mkurl("http", "test1", "/alive.json") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["protocol"] assert True == r["response"]["json"]["alive"] assert "test1" == r["response"]["json"]["host"]
def test_100_03(self): url = TestEnv.mkurl("https", "cgi", "/") hostname = ("test1.%s" % TestEnv.HTTP_TLD) r = TestEnv.curl_get(url, 5, [ "-H", "Host:%s" % hostname ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert "text/html" == r["response"]["header"]["content-type"]
def test_100_02(self): url = TestEnv.mkurl("https", "cgi", "/hello.py") hostname = ("cgi-alias.%s" % TestEnv.HTTP_TLD) r = TestEnv.curl_get(url, 5, [ "-H", "Host:%s" % hostname ]) assert 200 == r["response"]["status"] assert "HTTP/2" == r["response"]["protocol"] assert hostname == r["response"]["json"]["host"]
def check_necho(self, n, text): url = TestEnv.mkurl("https", "cgi", "/necho.py") r = TestEnv.curl_get(url, 5, [ "-F", ("count=%d" % (n)), "-F", ("text=%s" % (text)) ]) assert 200 == r["response"]["status"] exp = "" for i in range(n): exp += text + "\n" assert exp == r["response"]["body"]
def test_400_01(self): url = TestEnv.mkurl("https", "push", "/006-push.html") r = TestEnv.nghttp().get(url, options=["-Haccept-encoding: none"]) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert '/006/006.css' == promises[0]["request"]["header"][":path"] assert 216 == len(promises[0]["response"]["body"])
def test_201_04(self): url = TestEnv.mkurl("https", "test1", "/006.html") r = TestEnv.curl_get(url, options=[ "--http1.1", "-H", "Connection: keep-alive" ]) assert 200 == r["response"]["status"] assert "timeout=30, max=30" == r["response"]["header"]["keep-alive"] r = TestEnv.curl_get(url, options=[ "-H", "Connection: keep-alive" ]) assert 200 == r["response"]["status"] assert not "keep-alive" in r["response"]["header"]
def test_400_02(self): url = TestEnv.mkurl("https", "push", "/006-push.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] assert 13 == r["response"]["id"] assert 2 == len(r["streams"]) assert r["streams"][2] assert 216 == len(r["streams"][2]["response"]["body"])
def test_300_02(self): url = TestEnv.mkurl("https", "test1", "/index.html") r = TestEnv.curl_post_data(url, 'XYZ', options=["-H", "expect: 100-continue"]) assert 200 == r["response"]["status"] assert "previous" in r["response"] assert 100 == r["response"]["previous"]["status"]
def test_004_07(self, name, value): url = TestEnv.mkurl("https", "cgi", "/env.py") r = TestEnv.curl_post_value( url, "name", name ) assert r["rv"] == 0 assert r["response"]["status"] == 200 m = re.match("{0}=(.*)".format(name), r["response"]["body"].decode('utf-8')) assert m assert re.match(value, m.group(1))
def nghttp_upload_stat(self, fname, options=None): url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py") fpath = os.path.join(TestEnv.GEN_DIR, fname) r = TestEnv.nghttp().upload_file(url, fpath, options=options) assert r["rv"] == 0 assert r["response"]["status"] >= 200 and r["response"]["status"] < 300 assert r["response"]["header"]["location"]
def nghttp_upload_stat(self, fname, options=None): url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py") fpath = os.path.join(TestEnv.GEN_DIR, fname) r = TestEnv.nghttp().upload_file(url, fpath, options=options) assert r["rv"] == 0 assert 200 <= r["response"]["status"] < 300 assert r["response"]["header"]["location"]
def test_006_02(self): url = TestEnv.mkurl("https", "test1", "/002.jpg") r = TestEnv.nghttp().assets(url) assert 0 == r["rv"] assert 1 == len(r["assets"]) assert r["assets"] == [ { "status": 200, "size": "88K", "path" : "/002.jpg" } ]
def test_202_05(self): url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state") fpath = os.path.join(TestEnv.GEN_DIR, "data-1k") r = TestEnv.nghttp().upload(url, fpath, options=["--trailer", "test: 2"]) assert 200 == r["response"]["status"] assert "1" == r["response"]["trailer"]["h2-trailers-in"]
def check_necho(self, n, text): url = TestEnv.mkurl("https", "cgi", "/necho.py") r = TestEnv.curl_get(url, 5, [ "-F", ("count=%d" % (n)), "-F", ("text=%s" % (text)) ]) assert 200 == r["response"]["status"] exp = "" for i in range(n): exp += text + "\n" assert exp == r["response"]["body"]
def test_005_01(self): url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] st = r["response"]["json"] # remove some parts that are very dependant on client/lib versions # or connection time etc. del st["settings"]["SETTINGS_INITIAL_WINDOW_SIZE"] del st["peerSettings"]["SETTINGS_INITIAL_WINDOW_SIZE"] del st["streams"]["1"]["created"] del st["streams"]["1"]["flowOut"] del st["stats"]["in"]["frames"] del st["stats"]["in"]["octets"] del st["stats"]["out"]["frames"] del st["stats"]["out"]["octets"] del st["connFlowOut"] assert st == { "version": "draft-01", "settings": { "SETTINGS_MAX_CONCURRENT_STREAMS": 100, "SETTINGS_MAX_FRAME_SIZE": 16384, "SETTINGS_ENABLE_PUSH": 0 }, "peerSettings": { "SETTINGS_MAX_CONCURRENT_STREAMS": 100, "SETTINGS_MAX_FRAME_SIZE": 16384, "SETTINGS_ENABLE_PUSH": 0, "SETTINGS_HEADER_TABLE_SIZE": 4096, "SETTINGS_MAX_HEADER_LIST_SIZE": -1 }, "connFlowIn": 2147483647, "sentGoAway": 0, "streams": { "1": { "state": "HALF_CLOSED_REMOTE", "flowIn": 65535, "dataIn": 0, "dataOut": 0 } }, "stats": { "in": { "requests": 1, "resets": 0, }, "out": { "responses": 0, }, "push": { "cacheDigest": "AQg", "promises": 0, "submits": 0, "resets": 0 } } }
def test_005_01(self): url = TestEnv.mkurl("https", "cgi", "/.well-known/h2/state") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] st = r["response"]["json"] # remove some parts that are very dependant on client/lib versions # or connection time etc. del st["settings"]["SETTINGS_INITIAL_WINDOW_SIZE"] del st["peerSettings"]["SETTINGS_INITIAL_WINDOW_SIZE"] del st["streams"]["1"]["created"] del st["streams"]["1"]["flowOut"] del st["stats"]["in"]["frames"] del st["stats"]["in"]["octets"] del st["stats"]["out"]["frames"] del st["stats"]["out"]["octets"] del st["connFlowOut"] assert st == { "version" : "draft-01", "settings" : { "SETTINGS_MAX_CONCURRENT_STREAMS": 100, "SETTINGS_MAX_FRAME_SIZE": 16384, "SETTINGS_ENABLE_PUSH": 0 }, "peerSettings" : { "SETTINGS_MAX_CONCURRENT_STREAMS": 100, "SETTINGS_MAX_FRAME_SIZE": 16384, "SETTINGS_ENABLE_PUSH": 0, "SETTINGS_HEADER_TABLE_SIZE": 4096, "SETTINGS_MAX_HEADER_LIST_SIZE": -1 }, "connFlowIn": 2147483647, "sentGoAway": 0, "streams": { "1": { "state": "HALF_CLOSED_REMOTE", "flowIn": 65535, "dataIn": 0, "dataOut": 0 } }, "stats": { "in": { "requests": 1, "resets": 0, }, "out": { "responses": 0, }, "push": { "cacheDigest": "AQg", "promises": 0, "submits": 0, "resets": 0 } } }
def test_600_01(self): url = TestEnv.mkurl("https", "cgi", "/h2proxy/hello.py") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2.0" == r["response"]["json"]["protocol"] assert "on" == r["response"]["json"]["https"] assert "" != r["response"]["json"]["ssl_protocol"] assert "on" == r["response"]["json"]["h2"] assert "off" == r["response"]["json"]["h2push"]
def test_400_52(self): url = TestEnv.mkurl("https", "push", "/006-push.html") r = TestEnv.nghttp().get(url, options=[ '-H', 'accept-push-policy: head']) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) assert '/006/006.css' == promises[0]["request"]["header"][":path"] assert "" == promises[0]["response"]["body"] assert 0 == len(promises[0]["response"]["body"])
def test_006_05(self): url = TestEnv.mkurl("https", "test1", "/003.html") r = TestEnv.nghttp().assets(url, options=[ "--window-bits=24" ]) assert 0 == r["rv"] assert 2 == len(r["assets"]) assert r["assets"] == [ { "status": 200, "size": "316", "path": "/003.html" }, { "status": 200, "size": "88K", "path": "/003/003_img.jpg" } ]
def test_006_04(self): url = TestEnv.mkurl("https", "test1", "/006.html") r = TestEnv.nghttp().assets(url) assert 0 == r["rv"] assert 3 == len(r["assets"]) assert r["assets"] == [ { "status": 200, "size": "543", "path": "/006.html" }, { "status": 200, "size": "216", "path": "/006/006.css" }, { "status": 200, "size": "839", "path": "/006/006.js" } ]
def test_201_02(self): url = TestEnv.mkurl("https", "test1", "/006/006.css") r = TestEnv.curl_get(url) assert 200 == r["response"]["status"] etag = r["response"]["header"]["etag"] assert etag r = TestEnv.curl_get(url, options=[ "-H", "if-none-match: %s" % etag]) assert 304 == r["response"]["status"] r = TestEnv.curl_get(url, options=[ "-H", "if-none-match: dummy"]) assert 200 == r["response"]["status"]
def test_201_01(self): url = TestEnv.mkurl("https", "test1", "/006/006.css") r = TestEnv.curl_get(url) assert 200 == r["response"]["status"] lm = r["response"]["header"]["last-modified"] assert lm r = TestEnv.curl_get(url, options=[ "-H", "if-modified-since: %s" % lm]) assert 304 == r["response"]["status"] r = TestEnv.curl_get(url, options=[ "-H", "if-modified-since: Tue, 04 Sep 2010 11:51:59 GMT"]) assert 200 == r["response"]["status"]
def test_400_31(self): url = TestEnv.mkurl("https", "hints", "/006-hints.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 1 == len(promises) early = r["response"]["previous"] assert early assert 103 == int(early["header"][":status"]) assert early["header"]["link"]
def test_200_02(self): url = TestEnv.mkurl("https", "cgi", "/hecho.py") for x in range(1, 32): if 9 != x: r = TestEnv.curl_post_data(url, "name=x&value=y%%%02x" % x) if x in [ 10, 13 ]: assert 0 == r["rv"], "unexpected exit code for char 0x%02x" % x assert 200 == r["response"]["status"], "unexpected status for char 0x%02x" % x else: assert 0 != r["rv"], "unexpected exit code for char 0x%02x" % x
def nghttp_post_and_verify(self, fname, options=None): url = TestEnv.mkurl("https", "cgi", "/echo.py") fpath = os.path.join(TestEnv.GEN_DIR, fname) r = TestEnv.nghttp().upload(url, fpath, options=options) assert r["rv"] == 0 assert r["response"]["status"] >= 200 and r["response"]["status"] < 300 with open(TestEnv.e2e_src( fpath ), mode='rb') as file: src = file.read() assert src == r["response"]["body"]
def curl_upload_and_verify(self, fname, options=None): url = TestEnv.mkurl("https", "cgi", "/upload.py") fpath = os.path.join(TestEnv.GEN_DIR, fname) r = TestEnv.curl_upload(url, fpath, options=options) assert r["rv"] == 0 assert r["response"]["status"] >= 200 and r["response"]["status"] < 300 r2 = TestEnv.curl_get( r["response"]["header"]["location"]) assert r2["rv"] == 0 assert r2["response"]["status"] == 200 with open(TestEnv.e2e_src( fpath ), mode='rb') as file: src = file.read() assert src == r2["response"]["body"]
def test_400_20(self): url = TestEnv.mkurl("https", "push", "/006-push20.html") r = TestEnv.nghttp().get(url) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 2 == len(promises) fpath = os.path.join(TestEnv.GEN_DIR, "data-400-20") with open(fpath, 'w') as f: f.write("test upload data") r = TestEnv.nghttp().upload(url, fpath) assert 200 == r["response"]["status"] promises = r["streams"][r["response"]["id"]]["promises"] assert 0 == len(promises)
def test_101_05(self): url = TestEnv.mkurl("https", "ssl", "/ssl-client-verify/index.html") r = TestEnv.run( [ TestEnv.H2LOAD, "-n", "10", "-c", "1", "-m", "1", "-vvvv", "https://%s:%s/ssl-client-verify/index.html" % (TestEnv.HTTPD_ADDR, TestEnv.HTTPS_PORT)] ) assert 0 == r["rv"] r = TestEnv.h2load_status(r) assert 10 == r["h2load"]["requests"]["total"] assert 10 == r["h2load"]["requests"]["started"] assert 10 == r["h2load"]["requests"]["done"] assert 0 == r["h2load"]["requests"]["succeeded"] assert 0 == r["h2load"]["status"]["2xx"] assert 0 == r["h2load"]["status"]["3xx"] assert 0 == r["h2load"]["status"]["4xx"] assert 0 == r["h2load"]["status"]["5xx"]
def nghttp_upload_and_verify(self, fname, options=None): url = TestEnv.mkurl("https", "cgi", "/proxy/upload.py") fpath = os.path.join(TestEnv.GEN_DIR, fname) r = TestEnv.nghttp().upload_file(url, fpath, options=options) assert r["rv"] == 0 assert r["response"]["status"] >= 200 and r["response"]["status"] < 300 assert r["response"]["header"]["location"] # why is the scheme wrong? r2 = TestEnv.nghttp().get(re.sub(r'http:', 'https:', r["response"]["header"]["location"])) assert r2["rv"] == 0 assert r2["response"]["status"] == 200 with open(TestEnv.e2e_src( fpath ), mode='rb') as file: src = file.read() assert src == r2["response"]["body"]
def test_003_01(self): url = TestEnv.mkurl("https", "cgi", "/hello.py") r = TestEnv.curl_get(url, 5) assert 200 == r["response"]["status"] assert "HTTP/2.0" == r["response"]["json"]["protocol"] assert "on" == r["response"]["json"]["https"] assert "TLSv1.2" == r["response"]["json"]["ssl_protocol"] assert "on" == r["response"]["json"]["h2"] assert "off" == r["response"]["json"]["h2push"] r = TestEnv.curl_get(url, 5, [ "--http1.1" ]) assert 200 == r["response"]["status"] assert "HTTP/1.1" == r["response"]["json"]["protocol"] assert "on" == r["response"]["json"]["https"] assert "TLSv1.2" == r["response"]["json"]["ssl_protocol"] assert "" == r["response"]["json"]["h2"] assert "" == r["response"]["json"]["h2push"]