aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http/common.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2018-10-27 13:51:07 -0400
committerDave Henderson <dhenderson@gmail.com>2018-10-27 13:52:22 -0400
commit02a92b7617bfaf9d3bbe9992ec578fbea1cd15ab (patch)
treebccc576210096c9e58ec64712aa0edfbb6b12092 /plumbing/transport/http/common.go
parent4203e78713381a9af917fd4fc34b002511d67215 (diff)
downloadgo-git-02a92b7617bfaf9d3bbe9992ec578fbea1cd15ab.tar.gz
plumbing: transport/http, Add missing host/port on redirect. Fixes #820
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'plumbing/transport/http/common.go')
-rw-r--r--plumbing/transport/http/common.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go
index c034846..2909a06 100644
--- a/plumbing/transport/http/common.go
+++ b/plumbing/transport/http/common.go
@@ -4,6 +4,7 @@ package http
import (
"bytes"
"fmt"
+ "net"
"net/http"
"strconv"
"strings"
@@ -151,6 +152,18 @@ func (s *session) ModifyEndpointIfRedirect(res *http.Response) {
return
}
+ h, p, err := net.SplitHostPort(r.URL.Host)
+ if err != nil {
+ h = r.URL.Host
+ }
+ if p != "" {
+ port, err := strconv.Atoi(p)
+ if err == nil {
+ s.endpoint.Port = port
+ }
+ }
+ s.endpoint.Host = h
+
s.endpoint.Protocol = r.URL.Scheme
s.endpoint.Path = r.URL.Path[:len(r.URL.Path)-len(infoRefsPath)]
}