5
5
"fmt"
6
6
"io/ioutil"
7
7
"net/http"
8
- gohttp "net/http"
9
8
"os"
10
9
"path/filepath"
11
10
"strings"
@@ -14,7 +13,7 @@ import (
14
13
caopts "github.com/ipfs/interface-go-ipfs-core/options"
15
14
"github.com/mitchellh/go-homedir"
16
15
ma "github.com/multiformats/go-multiaddr"
17
- manet "github.com/multiformats/go-multiaddr- net"
16
+ manet "github.com/multiformats/go-multiaddr/ net"
18
17
)
19
18
20
19
const (
@@ -34,7 +33,7 @@ var ErrApiNotFound = errors.New("ipfs api address could not be found")
34
33
// https://godoc.org/github.com/ipfs/interface-go-ipfs-core#CoreAPI
35
34
type HttpApi struct {
36
35
url string
37
- httpcli gohttp .Client
36
+ httpcli http .Client
38
37
Headers http.Header
39
38
applyGlobal func (* requestBuilder )
40
39
}
@@ -85,9 +84,9 @@ func ApiAddr(ipfspath string) (ma.Multiaddr, error) {
85
84
86
85
// NewApi constructs HttpApi with specified endpoint
87
86
func 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 ,
91
90
DisableKeepAlives : true ,
92
91
},
93
92
}
@@ -96,7 +95,7 @@ func NewApi(a ma.Multiaddr) (*HttpApi, error) {
96
95
}
97
96
98
97
// 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 ) {
100
99
_ , url , err := manet .DialArgs (a )
101
100
if err != nil {
102
101
return nil , err
@@ -112,7 +111,7 @@ func NewApiWithClient(a ma.Multiaddr, c *gohttp.Client) (*HttpApi, error) {
112
111
return NewURLApiWithClient (url , c )
113
112
}
114
113
115
- func NewURLApiWithClient (url string , c * gohttp .Client ) (* HttpApi , error ) {
114
+ func NewURLApiWithClient (url string , c * http .Client ) (* HttpApi , error ) {
116
115
api := & HttpApi {
117
116
url : url ,
118
117
httpcli : * c ,
@@ -121,7 +120,7 @@ func NewURLApiWithClient(url string, c *gohttp.Client) (*HttpApi, error) {
121
120
}
122
121
123
122
// 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 {
125
124
return fmt .Errorf ("unexpected redirect" )
126
125
}
127
126
return api , nil
0 commit comments