コード例 #1
0
ファイル: test_600_h2proxy.py プロジェクト: atlesn/httpd
 def _class_scope(self, env):
     env.setup_data_1k_1m()
     conf = HttpdConf(env)
     conf.add_vhost_cgi(h2proxy_self=True)
     conf.add("LogLevel proxy_http2:trace2")
     conf.add("LogLevel proxy:trace2")
     conf.install()
     assert env.apache_restart() == 0
コード例 #2
0
ファイル: test_105_timeout.py プロジェクト: atlesn/httpd
 def test_105_01(self, env):
     conf = HttpdConf(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}")
         assert False
     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)
         assert False
     except Exception as ex:
         print(f"as expected: {ex}")
     sock.close()
コード例 #3
0
 def _class_scope(self, env):
     conf = HttpdConf(env).start_vhost(env.https_port, "ssl", with_ssl=True)
     conf.add("""
           Protocols h2 http/1.1
           SSLOptions +StdEnvVars
           <Location /h2only.html>
             Require expr \"%{HTTP2} == 'on'\"
           </Location>
           <Location /noh2.html>
             Require expr \"%{HTTP2} == 'off'\"
           </Location>""")
     conf.end_vhost()
     conf.install()
     # the dir needs to exists for the configuration to have effect
     env.mkpath("%s/htdocs/ssl-client-verify" % env.server_dir)
     assert env.apache_restart() == 0
コード例 #4
0
ファイル: test_400_push.py プロジェクト: atlesn/httpd
 def _class_scope(self, env):
     HttpdConf(env).start_vhost(
         env.https_port, "push", doc_root="htdocs/test1", with_ssl=True
     ).add(r"""    Protocols h2 http/1.1"
     RewriteEngine on
     RewriteRule ^/006-push(.*)?\.html$ /006.html
     <Location /006-push.html>
         Header add Link "</006/006.css>;rel=preload"
         Header add Link "</006/006.js>;rel=preloadX"
     </Location>
     <Location /006-push2.html>
         Header add Link "</006/006.css>;rel=preloadX, </006/006.js>; rel=preload"
     </Location>
     <Location /006-push3.html>
         Header add Link "</006/006.css>;rel=preloa,</006/006.js>;rel=preload"
     </Location>
     <Location /006-push4.html>
         Header add Link "</006/006.css;rel=preload, </006/006.js>; preload"
     </Location>
     <Location /006-push5.html>
         Header add Link '</006/006.css>;rel="preload push"'
     </Location>
     <Location /006-push6.html>
         Header add Link '</006/006.css>;rel="push preload"'
     </Location>
     <Location /006-push7.html>
         Header add Link '</006/006.css>;rel="abc preload push"'
     </Location>
     <Location /006-push8.html>
         Header add Link '</006/006.css>;rel="preload"; nopush'
     </Location>
     <Location /006-push20.html>
         H2PushResource "/006/006.css" critical
         H2PushResource "/006/006.js"
     </Location>    
     <Location /006-push30.html>
         H2Push off
         Header add Link '</006/006.css>;rel="preload"'
     </Location>
     <Location /006-push31.html>
         H2PushResource "/006/006.css" critical
     </Location>
     <Location /006-push32.html>
         Header add Link "</006/006.css>;rel=preload"
     </Location>
     """).end_vhost(
     ).install()
     assert env.apache_restart() == 0
コード例 #5
0
ファイル: test_401_early_hints.py プロジェクト: atlesn/httpd
 def _class_scope(self, env):
     HttpdConf(env).start_vhost(
         env.https_port, "hints", doc_root="htdocs/test1", with_ssl=True
     ).add("""    Protocols h2 http/1.1"
     H2EarlyHints on
     RewriteEngine on
     RewriteRule ^/006-(.*)?\\.html$ /006.html
     <Location /006-hints.html>
         H2PushResource "/006/006.css" critical
     </Location>
     <Location /006-nohints.html>
         Header add Link "</006/006.css>;rel=preload"
     </Location>
     """).end_vhost(
     ).install()
     assert env.apache_restart() == 0
コード例 #6
0
ファイル: test_105_timeout.py プロジェクト: atlesn/httpd
 def test_105_03(self, env):
     conf = HttpdConf(env)
     conf.add("""
         Timeout 10
         RequestReadTimeout handshake=1 header=5 body=10
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
     url = env.mkurl("https", "cgi", "/necho.py")
     r = env.curl_get(url, 5, [
         "-vvv",
         "-F",
         ("count=%d" % 100),
         "-F",
         ("text=%s" % "abcdefghijklmnopqrstuvwxyz"),
         "-F",
         ("wait1=%f" % 1.5),
     ])
     assert 200 == r.response["status"]
コード例 #7
0
 def test_200_15(self, env):
     conf = HttpdConf(env)
     conf.add("""
         LimitRequestLine 48
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
     url = env.mkurl("https", "cgi", "/")
     r = env.curl_get(url)
     assert 200 == r.response["status"]
     url = env.mkurl("https", "cgi", "/" + (48 * "x"))
     r = env.curl_get(url)
     assert 414 == r.response["status"]
     # nghttp sends the :method: header first (so far)
     # trigger a too long request line on it
     # the stream will RST and we get no response
     url = env.mkurl("https", "cgi", "/")
     opt = ["-H:method: {0}".format(100 * "x")]
     r = env.nghttp().get(url, options=opt)
     assert r.exit_code == 0, r
     assert not r.response
コード例 #8
0
ファイル: test_103_upgrade.py プロジェクト: atlesn/httpd
 def _class_scope(self, env):
     HttpdConf(env).add_vhost_test1().add_vhost_test2().add_vhost_noh2(
     ).start_vhost(
         env.https_port, "test3", doc_root="htdocs/test1", with_ssl=True
     ).add(
         """
         Protocols h2 http/1.1
         Header unset Upgrade"""
     ).end_vhost(
     ).start_vhost(
         env.http_port, "test1b", doc_root="htdocs/test1", with_ssl=False
     ).add(
         """
         Protocols h2c http/1.1
         H2Upgrade off
         <Location /006.html>
             H2Upgrade on
         </Location>"""
     ).end_vhost(
     ).install()
     assert env.apache_restart() == 0
コード例 #9
0
 def test_200_16(self, env):
     conf = HttpdConf(env)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
     url = env.mkurl("https", "cgi", "/hello.py")
     opt = ["-H:method: GET /hello.py"]
     r = env.nghttp().get(url, options=opt)
     assert r.exit_code == 0, r
     assert r.response
     assert r.response["status"] == 400
     url = env.mkurl("https", "cgi", "/proxy/hello.py")
     r = env.nghttp().get(url, options=opt)
     assert r.exit_code == 0, r
     assert r.response
     assert r.response["status"] == 400
コード例 #10
0
ファイル: test_004_post.py プロジェクト: atlesn/httpd
    def test_004_30(self, env):
        # issue: #203
        resource = "data-1k"
        full_length = 1000
        chunk = 200
        self.curl_upload_and_verify(env, resource, ["-v", "--http2"])
        logfile = os.path.join(env.server_logs_dir, "test_004_30")
        if os.path.isfile(logfile):
            os.remove(logfile)
        HttpdConf(env).add("""
LogFormat "{ \\"request\\": \\"%r\\", \\"status\\": %>s, \\"bytes_resp_B\\": %B, \\"bytes_tx_O\\": %O, \\"bytes_rx_I\\": %I, \\"bytes_rx_tx_S\\": %S }" issue_203
CustomLog logs/test_004_30 issue_203
        """).add_vhost_cgi().install()
        assert env.apache_restart() == 0
        url = env.mkurl("https", "cgi", "/files/{0}".format(resource))
        r = env.curl_get(url, 5, ["--http2"])
        assert 200 == r.response["status"]
        r = env.curl_get(
            url, 5,
            ["--http1.1", "-H", "Range: bytes=0-{0}".format(chunk - 1)])
        assert 206 == r.response["status"]
        assert chunk == len(r.response["body"].decode('utf-8'))
        r = env.curl_get(
            url, 5, ["--http2", "-H", "Range: bytes=0-{0}".format(chunk - 1)])
        assert 206 == r.response["status"]
        assert chunk == len(r.response["body"].decode('utf-8'))
        # now check what response lengths have actually been reported
        lines = open(logfile).readlines()
        log_h2_full = json.loads(lines[-3])
        log_h1 = json.loads(lines[-2])
        log_h2 = json.loads(lines[-1])
        assert log_h2_full['bytes_rx_I'] > 0
        assert log_h2_full['bytes_resp_B'] == 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_resp_B'] == chunk  # response bytes sent (payload)
        assert log_h1['bytes_tx_O'] > chunk  # output bytes sent
        assert log_h2['bytes_rx_I'] > 0
        assert log_h2['bytes_resp_B'] == chunk
        assert log_h2['bytes_tx_O'] > chunk
コード例 #11
0
 def _class_scope(self, env):
     HttpdConf(env).add(
         f"""
         SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384
         <Directory \"{env.server_dir}/htdocs/ssl-client-verify\"> 
             Require all granted
             SSLVerifyClient require
             SSLVerifyDepth 0
         </Directory>"""
     ).start_vhost(
         env.https_port, "ssl", with_ssl=True
     ).add(
         f"""
         Protocols h2 http/1.1"
         <Location /renegotiate/cipher>
             SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305
         </Location>
         <Location /renegotiate/err-doc-cipher>
             SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305
             ErrorDocument 403 /forbidden.html
         </Location>
         <Location /renegotiate/verify>
             SSLVerifyClient require
         </Location>
         <Directory \"{env.server_dir}/htdocs/sslrequire\"> 
             SSLRequireSSL
         </Directory>
         <Directory \"{env.server_dir}/htdocs/requiressl\"> 
             Require ssl
         </Directory>"""
     ).end_vhost().install()
     # the dir needs to exists for the configuration to have effect
     env.mkpath("%s/htdocs/ssl-client-verify" % env.server_dir)
     env.mkpath("%s/htdocs/renegotiate/cipher" % env.server_dir)
     env.mkpath("%s/htdocs/sslrequire" % env.server_dir)
     env.mkpath("%s/htdocs/requiressl" % env.server_dir)
     assert env.apache_restart() == 0
コード例 #12
0
 def _class_scope(self, env):
     setup_data(env)
     HttpdConf(env).add_vhost_cgi(h2proxy_self=True).install()
     assert env.apache_restart() == 0
コード例 #13
0
 def _class_scope(self, env):
     HttpdConf(env).add("""
         KeepAlive on
         MaxKeepAliveRequests 30
         KeepAliveTimeout 30""").add_vhost_test1().install()
     assert env.apache_restart() == 0
コード例 #14
0
ファイル: test_712_buffering.py プロジェクト: atlesn/httpd
 def _class_scope(self, env):
     env.setup_data_1k_1m()
     conf = HttpdConf(env).add("H2OutputBuffering off")
     conf.add_vhost_cgi(h2proxy_self=True).install()
     assert env.apache_restart() == 0
コード例 #15
0
 def _class_scope(self, env):
     HttpdConf(env).add_vhost_test1().add_vhost_test2().install()
     assert env.apache_restart() == 0
コード例 #16
0
 def _class_scope(self, env):
     conf = HttpdConf(env)
     conf.add_vhost_cgi()
     conf.start_vhost(env.https_port,
                      "pad0",
                      doc_root="htdocs/cgi",
                      with_ssl=True)
     conf.add("Protocols h2 http/1.1")
     conf.add("H2Padding 0")
     conf.add("AddHandler cgi-script .py")
     conf.end_vhost()
     conf.start_vhost(env.https_port,
                      "pad1",
                      doc_root="htdocs/cgi",
                      with_ssl=True)
     conf.add("Protocols h2 http/1.1")
     conf.add("H2Padding 1")
     conf.add("AddHandler cgi-script .py")
     conf.end_vhost()
     conf.start_vhost(env.https_port,
                      "pad2",
                      doc_root="htdocs/cgi",
                      with_ssl=True)
     conf.add("Protocols h2 http/1.1")
     conf.add("H2Padding 2")
     conf.add("AddHandler cgi-script .py")
     conf.end_vhost()
     conf.start_vhost(env.https_port,
                      "pad3",
                      doc_root="htdocs/cgi",
                      with_ssl=True)
     conf.add("Protocols h2 http/1.1")
     conf.add("H2Padding 3")
     conf.add("AddHandler cgi-script .py")
     conf.end_vhost()
     conf.start_vhost(env.https_port,
                      "pad8",
                      doc_root="htdocs/cgi",
                      with_ssl=True)
     conf.add("Protocols h2 http/1.1")
     conf.add("H2Padding 8")
     conf.add("AddHandler cgi-script .py")
     conf.end_vhost()
     conf.install()
     assert env.apache_restart() == 0
コード例 #17
0
 def test_200_14(self, env):
     conf = HttpdConf(env)
     conf.add("""
         LimitRequestFields 20
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
     url = env.mkurl("https", "cgi", "/")
     opt = []
     for i in range(21):
         opt += ["-H", "x{0}: 1".format(i)]
     r = env.curl_get(url, options=opt)
     assert 431 == r.response["status"]
     conf = HttpdConf(env)
     conf.add("""
         LimitRequestFields 0
         """)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
     url = env.mkurl("https", "cgi", "/")
     opt = []
     for i in range(100):
         opt += ["-H", "x{0}: 1".format(i)]
     r = env.curl_get(url, options=opt)
     assert 200 == r.response["status"]
コード例 #18
0
 def _class_scope(self, env):
     conf = HttpdConf(env)
     conf.add_vhost_cgi()
     conf.install()
     assert env.apache_restart() == 0
コード例 #19
0
 def _class_scope(self, env):
     env.setup_data_1k_1m()
     HttpdConf(env).add_vhost_test1().install()
     assert env.apache_restart() == 0
コード例 #20
0
 def _class_scope(self, env):
     HttpdConf(env).add_vhost_cgi(
         proxy_self=True,
         h2proxy_self=True).add_vhost_test1(proxy_self=True,
                                            h2proxy_self=True).install()
     assert env.apache_restart() == 0