from .env import H2Conf from pyhttpd.curl import CurlPiper
class TestTimeout:
# Check that base servers 'Timeout' setting is observed on SSL handshake def test_h2_105_01(self, env):
conf = H2Conf(env)
conf.add("""
AcceptFilter http none
Timeout 1.5 """)
conf.add_vhost_cgi()
conf.install() assert env.apache_restart() == 0
host = 'localhost' # read with a longer timeout than the server
sock = socket.create_connection((host, int(env.https_port))) try: # on some OS, the server does not see our connection until there is # something incoming
sock.send(b'0')
sock.settimeout(4)
buff = sock.recv(1024) assert buff == b'' except Exception as ex:
print(f"server did not close in time: {ex}") assertFalse
sock.close() # read with a shorter timeout than the server
sock = socket.create_connection((host, int(env.https_port))) try:
sock.settimeout(0.5)
sock.recv(1024) assertFalse except Exception as ex:
print(f"as expected: {ex}")
sock.close() #
time.sleep(1) # let the log flush
env.httpd_error_log.ignore_recent(
lognos = [ "AH10373"# SSL handshake was not completed
]
)
# Check that mod_reqtimeout handshake setting takes effect def test_h2_105_02(self, env):
conf = H2Conf(env)
conf.add("""
AcceptFilter http none
Timeout 10
RequestReadTimeout handshake=1 header=5 body=10 """)
conf.add_vhost_cgi()
conf.install() assert env.apache_restart() == 0
host = 'localhost' # read with a longer timeout than the server
sock = socket.create_connection((host, int(env.https_port))) try: # on some OS, the server does not see our connection until there is # something incoming
sock.send(b'0')
sock.settimeout(4)
buff = sock.recv(1024) assert buff == b'' except Exception as ex:
print(f"server did not close in time: {ex}") assertFalse
sock.close() # read with a shorter timeout than the server
sock = socket.create_connection((host, int(env.https_port))) try:
sock.settimeout(0.5)
sock.recv(1024) assertFalse except Exception as ex:
print(f"as expected: {ex}")
sock.close() #
time.sleep(1) # let the log flush
env.httpd_error_log.ignore_recent(
lognos = [ "AH10373"# SSL handshake was not completed
]
)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.