mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
parent
f94219e737
commit
ebccc103d8
@ -348,9 +348,12 @@ class HttpLayer(base.Layer):
|
|||||||
elif self.mode == "upstream":
|
elif self.mode == "upstream":
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Don't set .host directly, that would update the host header.
|
# Setting request.host also updates the host header, which we want to preserve
|
||||||
flow.request.data.host = self.__initial_server_conn.address.host
|
host_header = flow.request.headers.get("host", None)
|
||||||
flow.request.data.port = self.__initial_server_conn.address.port
|
flow.request.host = self.__initial_server_conn.address.host
|
||||||
|
flow.request.port = self.__initial_server_conn.address.port
|
||||||
|
if host_header:
|
||||||
|
flow.request.headers["host"] = host_header
|
||||||
flow.request.scheme = "https" if self.__initial_server_tls else "http"
|
flow.request.scheme = "https" if self.__initial_server_tls else "http"
|
||||||
|
|
||||||
request_reply = self.channel.ask("request", flow)
|
request_reply = self.channel.ask("request", flow)
|
||||||
@ -377,10 +380,10 @@ class HttpLayer(base.Layer):
|
|||||||
raise exceptions.HttpProtocolException("Cannot change scheme in upstream proxy mode.")
|
raise exceptions.HttpProtocolException("Cannot change scheme in upstream proxy mode.")
|
||||||
"""
|
"""
|
||||||
# This is a very ugly (untested) workaround to solve a very ugly problem.
|
# This is a very ugly (untested) workaround to solve a very ugly problem.
|
||||||
if self.server_conn and self.server_conn.tls_established and not tls:
|
if self.server_conn and self.server_conn.tls_established and not ssl:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.connect()
|
self.connect()
|
||||||
elif tls and not hasattr(self, "connected_to") or self.connected_to != address:
|
elif ssl and not hasattr(self, "connected_to") or self.connected_to != address:
|
||||||
if self.server_conn.tls_established:
|
if self.server_conn.tls_established:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.connect()
|
self.connect()
|
||||||
|
Loading…
Reference in New Issue
Block a user