we do not support https2http in upstream proxy mode

This commit is contained in:
Maximilian Hils 2015-01-01 22:07:49 +01:00
parent 4d01e22f26
commit c152e5da1a
2 changed files with 18 additions and 24 deletions

View File

@ -11,17 +11,3 @@ mitmproxy forwards ordinary HTTP requests to an upstream server.
</tr>
</tbody>
</table>
Here, **schema** is one of http, https, http2https or https2http. The latter
two extended schema specifications control the use of HTTP and HTTPS on
mitmproxy and the upstream server. You can indicate that mitmproxy should use
HTTP, and the upstream server uses HTTPS like this:
http2https://hostname:port
And you can indicate that mitmproxy should use HTTPS while the upstream
service uses HTTP like this:
https2http://hostname:port

View File

@ -100,19 +100,13 @@ def parse_setheader(s):
def parse_server_spec(url):
normalized_url = re.sub("^https?2", "", url)
p = http.parse_url(normalized_url)
if not p or not p[1]:
p = http.parse_url(url)
if not p or not p[1] or p[0] not in ("http", "https"):
raise configargparse.ArgumentTypeError(
"Invalid server specification: %s" % url
)
if url.lower().startswith("https2http"):
ssl = [True, False]
elif url.lower().startswith("http2https"):
ssl = [False, True]
elif url.lower().startswith("https"):
if p[0].lower() == "https":
ssl = [True, True]
else:
ssl = [False, False]
@ -120,6 +114,20 @@ def parse_server_spec(url):
return ssl + list(p[1:3])
def parse_server_spec_special(url):
"""
Provides additional support for http2https and https2http schemes.
"""
normalized_url = re.sub("^https?2", "", url)
ret = parse_server_spec(normalized_url)
if url.lower().startswith("https2http"):
ret[0] = True
elif url.lower().startswith("http2https"):
ret[0] = False
return ret
def get_common_options(options):
stickycookie, stickyauth = None, None
if options.stickycookie_filt:
@ -336,7 +344,7 @@ def common_options(parser):
group.add_argument(
"-R", "--reverse",
action="store",
type=parse_server_spec,
type=parse_server_spec_special,
dest="reverse_proxy",
default=None,
help="""