Skip to content

Commit

Permalink
fix file download problem with a urls which includes a port huydx#9
Browse files Browse the repository at this point in the history
  • Loading branch information
jhezjkp committed Aug 13, 2016
1 parent 03213a9 commit 41aac29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ func NewHttpDownloader(url string, par int, skipTls bool) *HttpDownloader {
var resumable = true

parsed, err := stdurl.Parse(url)
var host = parsed.Host
var portIndex = strings.Index(host, ":")
if portIndex >= 0 {
host = host[0:portIndex]
}
FatalCheck(err)

ips, err := net.LookupIP(parsed.Host)
ips, err := net.LookupIP(host)
FatalCheck(err)

ipstr := FilterIPV4(ips)
Expand Down
7 changes: 7 additions & 0 deletions http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ func TestPartCalculate(t *testing.T) {
t.Fatalf("part range was wrong")
}
}

func TestNewHttpDownloader(t *testing.T) {
displayProgress = false

NewHttpDownloader("http://www.golangtc.com:80/static/go/1.7rc6/go1.7rc6.darwin-amd64.pkg", 1, true)
NewHttpDownloader("http://www.golangtc.com/static/go/1.7rc6/go1.7rc6.darwin-amd64.pkg", 1, true)
}

0 comments on commit 41aac29

Please sign in to comment.