mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
http2: improve :authority header
This commit is contained in:
parent
abb37a3ef5
commit
eb823a04a1
@ -171,6 +171,9 @@ class HTTP2Protocol(object):
|
||||
headers = []
|
||||
|
||||
authority = self.tcp_handler.sni if self.tcp_handler.sni else self.tcp_handler.address.host
|
||||
if self.tcp_handler.address.port != 443:
|
||||
authority += ":%d" % self.tcp_handler.address.port
|
||||
|
||||
headers = [
|
||||
(b':method', bytes(method)),
|
||||
(b':path', bytes(path)),
|
||||
|
@ -222,14 +222,14 @@ class TestCreateRequest():
|
||||
def test_create_request_simple(self):
|
||||
bytes = http2.HTTP2Protocol(self.c).create_request('GET', '/')
|
||||
assert len(bytes) == 1
|
||||
assert bytes[0] == '00000c0105000000018284874187089d5c0b8170ff'.decode('hex')
|
||||
assert bytes[0] == '00000d0105000000018284874188089d5c0b8170dc07'.decode('hex')
|
||||
|
||||
def test_create_request_with_body(self):
|
||||
bytes = http2.HTTP2Protocol(self.c).create_request(
|
||||
'GET', '/', [(b'foo', b'bar')], 'foobar')
|
||||
assert len(bytes) == 2
|
||||
assert bytes[0] ==\
|
||||
'0000140104000000018284874187089d5c0b8170ff408294e7838c767f'.decode('hex')
|
||||
'0000150104000000018284874188089d5c0b8170dc07408294e7838c767f'.decode('hex')
|
||||
assert bytes[1] ==\
|
||||
'000006000100000001666f6f626172'.decode('hex')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user