"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/e2e/test_004_post.py" between
mod_http2-1.15.16.tar.gz and mod_http2-1.15.17.tar.gz

About: mod_h[ttp]2 is an Apache httpd module implementing the HTTP2 protocol. It uses nghttp2 as base engine and connects it with the Apache infrastructure. Hint: Module (previous name "mod_h2") now integrated into Apache httpd (since v2.4.17). Experimental release.

test_004_post.py  (mod_http2-1.15.16):test_004_post.py  (mod_http2-1.15.17)
# #
# mod-h2 test suite # mod-h2 test suite
# check POST variations # check POST variations
# #
import copy import datetime
import email.parser
import json import json
import os import os
import re import re
import sys import sys
import time import time
import pytest import pytest
import subprocess
from datetime import datetime from threading import Thread
from TestEnv import TestEnv from TestEnv import TestEnv
from TestHttpdConf import HttpdConf from TestHttpdConf import HttpdConf
def setup_module(module): def setup_module(module):
print("setup_module: %s" % module.__name__) print("setup_module: %s" % module.__name__)
TestEnv.init() TestEnv.init()
TestEnv.setup_data_1k_1m() TestEnv.setup_data_1k_1m()
HttpdConf().add_vhost_cgi().install() HttpdConf().add_vhost_cgi().install()
assert TestEnv.apache_restart() == 0 assert TestEnv.apache_restart() == 0
skipping to change at line 83 skipping to change at line 85
def test_004_06(self): def test_004_06(self):
self.curl_upload_and_verify( "data-1k", [ "--http1.1", "-H", "Content-Le ngth: " ] ) self.curl_upload_and_verify( "data-1k", [ "--http1.1", "-H", "Content-Le ngth: " ] )
self.curl_upload_and_verify( "data-1k", [ "--http2", "-H", "Content-Leng th: " ] ) self.curl_upload_and_verify( "data-1k", [ "--http2", "-H", "Content-Leng th: " ] )
@pytest.mark.parametrize("name, value", [ @pytest.mark.parametrize("name, value", [
( "HTTP2", "on"), ( "HTTP2", "on"),
( "H2PUSH", "off"), ( "H2PUSH", "off"),
( "H2_PUSHED", ""), ( "H2_PUSHED", ""),
( "H2_PUSHED_ON", ""), ( "H2_PUSHED_ON", ""),
( "H2_STREAM_ID", "1"), ( "H2_STREAM_ID", "1"),
( "H2_STREAM_TAG", "\d+-1"), ( "H2_STREAM_TAG", r'\d+-1'),
]) ])
def test_004_07(self, name, value): def test_004_07(self, name, value):
url = TestEnv.mkurl("https", "cgi", "/env.py") url = TestEnv.mkurl("https", "cgi", "/env.py")
r = TestEnv.curl_post_value( url, "name", name ) r = TestEnv.curl_post_value( url, "name", name )
assert r["rv"] == 0 assert r["rv"] == 0
assert r["response"]["status"] == 200 assert r["response"]["status"] == 200
m = re.match("{0}=(.*)".format(name), r["response"]["body"].decode('utf- 8')) m = re.match("{0}=(.*)".format(name), r["response"]["body"].decode('utf- 8'))
assert m assert m
assert re.match(value, m.group(1)) assert re.match(value, m.group(1))
skipping to change at line 214 skipping to change at line 216
log_h2 = json.loads(lines[-1]) log_h2 = json.loads(lines[-1])
assert log_h2_full['bytes_rx_I'] > 0 assert log_h2_full['bytes_rx_I'] > 0
assert log_h2_full['bytes_resp_B'] == full_length assert log_h2_full['bytes_resp_B'] == full_length
assert log_h2_full['bytes_tx_O'] > full_length assert log_h2_full['bytes_tx_O'] > full_length
assert log_h1['bytes_rx_I'] > 0 # input bytes recieved assert log_h1['bytes_rx_I'] > 0 # input bytes recieved
assert log_h1['bytes_resp_B'] == chunk # response bytes sent (payload) assert log_h1['bytes_resp_B'] == chunk # response bytes sent (payload)
assert log_h1['bytes_tx_O'] > chunk # output bytes sent assert log_h1['bytes_tx_O'] > chunk # output bytes sent
assert log_h2['bytes_rx_I'] > 0 assert log_h2['bytes_rx_I'] > 0
assert log_h2['bytes_resp_B'] == chunk assert log_h2['bytes_resp_B'] == chunk
assert log_h2['bytes_tx_O'] > chunk assert log_h2['bytes_tx_O'] > chunk
def test_004_40(self):
# echo content using h2test_module "echo" handler
def post_and_verify(fname, options=None):
url = TestEnv.mkurl("https", "cgi", "/h2test/echo")
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
ct = r["response"]["header"]["content-type"]
mail_hd = "Content-Type: " + ct + "\r\nMIME-Version: 1.0\r\n\r\n"
mime_msg = mail_hd.encode() + r["response"]["body"]
# this MIME API is from hell
body = email.parser.BytesParser().parsebytes(mime_msg)
assert body
assert body.is_multipart()
filepart = None
for part in body.walk():
if fname == part.get_filename():
filepart = part
assert filepart
with open(TestEnv.e2e_src( fpath ), mode='rb') as file:
src = file.read()
assert src == filepart.get_payload(decode=True)
post_and_verify( "data-1k", [ ] )
 End of changes. 5 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)