From d4c3e8842602e0192657fcf05f1804fbfc7f54fd Mon Sep 17 00:00:00 2001 From: Troels Thomsen Date: Mon, 20 Mar 2017 16:10:36 -0700 Subject: [PATCH] Add test for precendence with standard port Signed-off-by: Troels Thomsen Signed-off-by: Derek McGowan (github: dmcgowan) --- registry/api/v2/urls_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/registry/api/v2/urls_test.go b/registry/api/v2/urls_test.go index 6449c6e4..dae8354b 100644 --- a/registry/api/v2/urls_test.go +++ b/registry/api/v2/urls_test.go @@ -264,6 +264,22 @@ func TestBuilderFromRequest(t *testing.T) { }}, base: "http://example.com:443", }, + { + name: "forwarded standard port with non-standard headers", + request: &http.Request{URL: u, Host: u.Host, Header: http.Header{ + "X-Forwarded-Proto": []string{"https"}, + "X-Forwarded-Port": []string{"443"}, + }}, + base: "https://example.com", + }, + { + name: "forwarded standard port with non-standard headers and explicit port", + request: &http.Request{URL: u, Host: u.Host + ":443", Header: http.Header{ + "X-Forwarded-Proto": []string{"https"}, + "X-Forwarded-Port": []string{"443"}, + }}, + base: "https://example.com:443", + }, { name: "several non-standard headers", request: &http.Request{URL: u, Host: u.Host, Header: http.Header{