Documentation ¶
Overview ¶
Package httputil provides additional helper functions for http services NOTE: Subject to change, do not rely on this package from outside git-lfs source
Index ¶
- Variables
- func CheckRedirect(req *http.Request, via []*http.Request) error
- func DecodeResponse(res *http.Response, obj interface{}) error
- func DoHttpRequest(cfg *config.Configuration, req *http.Request, useCreds bool) (*http.Response, error)
- func DoHttpRequestWithRedirects(cfg *config.Configuration, req *http.Request, via []*http.Request, ...) (*http.Response, error)
- func GetAuthType(res *http.Response) string
- func GetDefaultError(code int) string
- func LogHttpStats(cfg *config.Configuration)
- func LogTransfer(cfg *config.Configuration, key string, res *http.Response)
- func NewHttpRequest(method, rawurl string, header map[string]string) (*http.Request, error)
- func ProxyFromGitConfigOrEnvironment(c *config.Configuration) func(req *http.Request) (*url.URL, error)
- func SetAuthType(cfg *config.Configuration, req *http.Request, res *http.Response)
- func SetErrorResponseContext(cfg *config.Configuration, err error, res *http.Response)
- func TraceHttpReq(req *http.Request) string
- type ClientError
- type CountingReadCloser
- type HttpClient
Constants ¶
This section is empty.
Variables ¶
var (
UserAgent string
)
Functions ¶
func DecodeResponse ¶
DecodeResponse attempts to decode the contents of the response as a JSON object
func DoHttpRequest ¶
func DoHttpRequest(cfg *config.Configuration, req *http.Request, useCreds bool) (*http.Response, error)
DoHttpRequest performs a single HTTP request
func DoHttpRequestWithRedirects ¶
func DoHttpRequestWithRedirects(cfg *config.Configuration, req *http.Request, via []*http.Request, useCreds bool) (*http.Response, error)
DoHttpRequestWithRedirects runs a HTTP request and responds to redirects
func GetAuthType ¶
func GetDefaultError ¶
GetDefaultError returns the default text for standard error codes (blank if none)
func LogHttpStats ¶
func LogHttpStats(cfg *config.Configuration)
LogHttpStats is intended to be called after all HTTP operations for the commmand have finished. It dumps k/v logs, one line per httpTransfer into a log file with the current timestamp.
func LogTransfer ¶
func LogTransfer(cfg *config.Configuration, key string, res *http.Response)
func NewHttpRequest ¶
NewHttpRequest creates a template request, with the given headers & UserAgent supplied
func ProxyFromGitConfigOrEnvironment ¶
func ProxyFromGitConfigOrEnvironment(c *config.Configuration) func(req *http.Request) (*url.URL, error)
Logic is copied, with small changes, from "net/http".ProxyFromEnvironment in the go std lib.
func SetAuthType ¶
func SetErrorResponseContext ¶
func SetErrorResponseContext(cfg *config.Configuration, err error, res *http.Response)
func TraceHttpReq ¶
Types ¶
type ClientError ¶
type ClientError struct { Message string `json:"message"` DocumentationUrl string `json:"documentation_url,omitempty"` RequestId string `json:"request_id,omitempty"` }
func (*ClientError) Error ¶
func (e *ClientError) Error() string
type CountingReadCloser ¶
type CountingReadCloser struct { Count int io.ReadCloser // contains filtered or unexported fields }
type HttpClient ¶
type HttpClient struct { Config *config.Configuration *http.Client }
func NewHttpClient ¶
func NewHttpClient(c *config.Configuration, host string) *HttpClient
NewHttpClient returns a new HttpClient for the given host (which may be "host:port")