httputil

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2016 License: MIT Imports: 26 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	UserAgent string
)

Functions

func CheckRedirect

func CheckRedirect(req *http.Request, via []*http.Request) error

func DecodeResponse

func DecodeResponse(res *http.Response, obj interface{}) error

DecodeResponse attempts to decode the contents of the response as a JSON object

func DoHttpRequest

func DoHttpRequest(req *http.Request, useCreds bool) (*http.Response, error)

DoHttpRequest performs a single HTTP request

func DoHttpRequestWithRedirects

func DoHttpRequestWithRedirects(req *http.Request, via []*http.Request, useCreds bool) (*http.Response, error)

DoHttpRequestWithRedirects runs a HTTP request and responds to redirects

func GetAuthType

func GetAuthType(res *http.Response) string

func GetDefaultError

func GetDefaultError(code int) string

GetDefaultError returns the default text for standard error codes (blank if none)

func LogHttpStats

func LogHttpStats()

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(key string, res *http.Response)

func NewHttpRequest

func NewHttpRequest(method, rawurl string, header map[string]string) (*http.Request, error)

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 SetAuthType(req *http.Request, res *http.Response)

func SetErrorResponseContext

func SetErrorResponseContext(err error, res *http.Response)

func TraceHttpReq

func TraceHttpReq(req *http.Request) string

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
}

func (*CountingReadCloser) Read

func (c *CountingReadCloser) Read(b []byte) (int, error)

type HttpClient

type HttpClient struct {
	*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")

func (*HttpClient) Do

func (c *HttpClient) Do(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL