From c8938fc0331bd6620e0ccf8604eae6652ede1ef7 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 14 Apr 2023 14:06:44 +0200 Subject: [PATCH] fix ipv4 location header on dualstack --- copyparty/httpcli.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 4cf02a9f..19712af4 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -264,9 +264,10 @@ class HttpCli(object): self.is_https = ( self.headers.get("x-forwarded-proto", "").lower() == "https" or self.tls ) - self.host = self.headers.get("host") or "{}:{}".format( - *list(self.s.getsockname()[:2]) - ) + self.host = self.headers.get("host") + if not self.host: + zs = "{}:{}".format(*list(self.s.getsockname()[:2])) + self.host = zs[7:] if zs.startswith("::ffff:") else zs n = self.args.rproxy if n: