-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttp.go
More file actions
28 lines (24 loc) · 726 Bytes
/
http.go
File metadata and controls
28 lines (24 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package webhdfs
import (
"io"
"net/http"
"net/url"
krb "github.com/jcmturner/gokrb5/v8/client"
"github.com/jcmturner/gokrb5/v8/spnego"
)
type HttpClient interface {
Head(url string) (resp *http.Response, err error)
Get(url string) (resp *http.Response, err error)
Post(url, contentType string, body io.Reader) (resp *http.Response, err error)
PostForm(url string, data url.Values) (resp *http.Response, err error)
Do(req *http.Request) (*http.Response, error)
}
func GetHttpClient(httpCl *http.Client, kerberosClient *krb.Client, spn string) HttpClient {
if kerberosClient == nil {
if httpCl != nil {
return httpCl
}
return http.DefaultClient
}
return spnego.NewClient(kerberosClient, httpCl, spn)
}