55 "fmt"
66 "io/ioutil"
77 "net/http"
8- gohttp "net/http"
98 "os"
109 "path/filepath"
1110 "strings"
@@ -14,7 +13,7 @@ import (
1413 caopts "github.com/ipfs/interface-go-ipfs-core/options"
1514 "github.com/mitchellh/go-homedir"
1615 ma "github.com/multiformats/go-multiaddr"
17- manet "github.com/multiformats/go-multiaddr- net"
16+ manet "github.com/multiformats/go-multiaddr/ net"
1817)
1918
2019const (
@@ -34,7 +33,7 @@ var ErrApiNotFound = errors.New("ipfs api address could not be found")
3433// https://godoc.org/github.com/ipfs/interface-go-ipfs-core#CoreAPI
3534type HttpApi struct {
3635 url string
37- httpcli gohttp .Client
36+ httpcli http .Client
3837 Headers http.Header
3938 applyGlobal func (* requestBuilder )
4039}
@@ -85,9 +84,9 @@ func ApiAddr(ipfspath string) (ma.Multiaddr, error) {
8584
8685// NewApi constructs HttpApi with specified endpoint
8786func NewApi (a ma.Multiaddr ) (* HttpApi , error ) {
88- c := & gohttp .Client {
89- Transport : & gohttp .Transport {
90- Proxy : gohttp .ProxyFromEnvironment ,
87+ c := & http .Client {
88+ Transport : & http .Transport {
89+ Proxy : http .ProxyFromEnvironment ,
9190 DisableKeepAlives : true ,
9291 },
9392 }
@@ -96,7 +95,7 @@ func NewApi(a ma.Multiaddr) (*HttpApi, error) {
9695}
9796
9897// NewApiWithClient constructs HttpApi with specified endpoint and custom http client
99- func NewApiWithClient (a ma.Multiaddr , c * gohttp .Client ) (* HttpApi , error ) {
98+ func NewApiWithClient (a ma.Multiaddr , c * http .Client ) (* HttpApi , error ) {
10099 _ , url , err := manet .DialArgs (a )
101100 if err != nil {
102101 return nil , err
@@ -112,7 +111,7 @@ func NewApiWithClient(a ma.Multiaddr, c *gohttp.Client) (*HttpApi, error) {
112111 return NewURLApiWithClient (url , c )
113112}
114113
115- func NewURLApiWithClient (url string , c * gohttp .Client ) (* HttpApi , error ) {
114+ func NewURLApiWithClient (url string , c * http .Client ) (* HttpApi , error ) {
116115 api := & HttpApi {
117116 url : url ,
118117 httpcli : * c ,
@@ -121,7 +120,7 @@ func NewURLApiWithClient(url string, c *gohttp.Client) (*HttpApi, error) {
121120 }
122121
123122 // We don't support redirects.
124- api .httpcli .CheckRedirect = func (_ * gohttp .Request , _ []* gohttp .Request ) error {
123+ api .httpcli .CheckRedirect = func (_ * http .Request , _ []* http .Request ) error {
125124 return fmt .Errorf ("unexpected redirect" )
126125 }
127126 return api , nil
0 commit comments