Skip to content

Commit 2c929ae

Browse files
committed
Adds test for missing header in h2 proxy
1 parent e26ed1f commit 2c929ae

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/modules/http2/test_600_h2proxy.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import re
2+
import socket
3+
import textwrap
4+
15
import pytest
26

37
from .env import H2Conf, H2TestEnv
@@ -198,3 +202,29 @@ def test_h2_600_32(self, env, repeat):
198202
# stream (exit_code != 0) or give a 503 response.
199203
if r.exit_code == 0:
200204
assert r.response['status'] in [502, 503]
205+
206+
# test missing host header
207+
def test_h2_600_33(self, env):
208+
conf = H2Conf(env, extras={
209+
'base': [
210+
'ProxyPreserveHost on',
211+
f'ProxyPass /test/ h2c://127.0.0.1:{env.http_port}/',
212+
],
213+
})
214+
conf.install()
215+
assert env.apache_restart() == 0
216+
217+
with socket.create_connection(('localhost', int(env.http_port))) as sock:
218+
sock.sendall("GET /test/\r\n\r\n".encode())
219+
sock.shutdown(socket.SHUT_WR)
220+
sock.recv(1024)
221+
log_message = re.compile(
222+
r'.*HTTP/0\.9 request \(with no Host header\)'
223+
r' and preserve host set, forcing hostname.*'
224+
)
225+
assert env.httpd_error_log.scan_recent(log_message, timeout=5)
226+
env.httpd_error_log.ignore_recent(matches=[
227+
r'.*HTTP/0\.9 request \(with no Host header\).*',
228+
], lognos=[
229+
"AH10511"
230+
])

0 commit comments

Comments
 (0)