MM-10417 Improve HTTPService for use in image proxy (#9966)

* Replaced httpservice with proper http.Client

* Added HTTPService.MakeTransport

* Expose timeouts used by HTTPServiceImpl

* Add additional documentation to HTTPService

* Remove MockedHTTPService

* Fix missing license
Этот коммит содержится в:
Harrison Healey
2018-12-12 11:39:14 -05:00
коммит произвёл GitHub
родитель f42c00ee53
Коммит 749a3e7538
9 изменённых файлов: 60 добавлений и 151 удалений

Просмотреть файл

@@ -16,7 +16,7 @@ import (
func TestHTTPClient(t *testing.T) {
for _, allowInternal := range []bool{true, false} {
c := NewHTTPClient(false, func(_ string) bool { return false }, func(ip net.IP) bool { return allowInternal || !IsReservedIP(ip) })
c := NewHTTPClient(NewTransport(false, func(_ string) bool { return false }, func(ip net.IP) bool { return allowInternal || !IsReservedIP(ip) }))
for _, tc := range []struct {
URL string
IsInternal bool
@@ -56,9 +56,9 @@ func TestHTTPClientWithProxy(t *testing.T) {
proxy := createProxyServer()
defer proxy.Close()
c := NewHTTPClient(true, nil, nil)
c := NewHTTPClient(NewTransport(true, nil, nil))
purl, _ := url.Parse(proxy.URL)
c.Transport.(*http.Transport).Proxy = http.ProxyURL(purl)
c.Transport.(*MattermostTransport).Transport.(*http.Transport).Proxy = http.ProxyURL(purl)
resp, err := c.Get("http://acme.com")
if err != nil {
@@ -132,7 +132,7 @@ func TestUserAgentIsSet(t *testing.T) {
}
}))
defer ts.Close()
client := NewHTTPClient(true, nil, nil)
client := NewHTTPClient(NewTransport(true, nil, nil))
req, err := http.NewRequest("GET", ts.URL, nil)
if err != nil {
t.Fatal("NewRequest failed", err)