Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-08 15:02:14 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-08 15:02:14 +0300
commit5ae747b1c800d02a4535fb1be0fdfcbc3ea0001e (patch)
treedbb89a7dc59b76cfe224cc881360d17c6250ae3a /internal/source
parent76b6d671858b44d026300752e4d37ea3d0a1e4bc (diff)
Add support for the port component in the Host header
Diffstat (limited to 'internal/source')
-rw-r--r--internal/source/gitlab/client/client_stub.go2
-rw-r--r--internal/source/gitlab/gitlab.go4
2 files changed, 4 insertions, 2 deletions
diff --git a/internal/source/gitlab/client/client_stub.go b/internal/source/gitlab/client/client_stub.go
index 6dc0af85..252ad422 100644
--- a/internal/source/gitlab/client/client_stub.go
+++ b/internal/source/gitlab/client/client_stub.go
@@ -15,10 +15,10 @@ type StubClient struct {
// GetVirtualDomain reads a test fixture and unmarshalls it
func (c StubClient) GetVirtualDomain(host string) (*api.VirtualDomain, error) {
f, err := os.Open(c.File)
- defer f.Close()
if err != nil {
return nil, err
}
+ defer f.Close()
var domain api.VirtualDomain
err = json.NewDecoder(f).Decode(&domain)
diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go
index a2911e6b..6a8573e5 100644
--- a/internal/source/gitlab/gitlab.go
+++ b/internal/source/gitlab/gitlab.go
@@ -7,6 +7,7 @@ import (
"strings"
"gitlab.com/gitlab-org/gitlab-pages/internal/domain"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/request"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
"gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/cache"
"gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/client"
@@ -50,7 +51,8 @@ func (g *Gitlab) GetDomain(name string) (*domain.Domain, error) {
// Resolve is supposed to get the serving lookup path based on the request from
// the GitLab source
func (g *Gitlab) Resolve(r *http.Request) (*serving.LookupPath, string, error) {
- response, err := g.client.GetVirtualDomain(r.Host)
+ host := request.GetHostWithoutPort(r)
+ response, err := g.client.GetVirtualDomain(host)
if err != nil {
return nil, "", err
}