lfshttp

package
v2.13.1-0...-077e46b Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: BSD-3-Clause, MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const MediaType = "application/vnd.git-lfs+json; charset=utf-8"
View Source
const UrlUnknown = "<unknown>"

Variables

View Source
var (
	UserAgent = "git-lfs"
)

Functions

func DecodeJSON

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

func IsDecodeTypeError

func IsDecodeTypeError(err error) bool

func IsHTTP

func IsHTTP(err error) (*http.Response, bool)

func MarshalToRequest

func MarshalToRequest(req *http.Request, obj interface{}) error

func NewStatusCodeError

func NewStatusCodeError(res *http.Response) error

func Retries

func Retries(req *http.Request) (int, bool)

Retries returns the number of retries requested for a given http.Request.

func WithRetries

func WithRetries(req *http.Request, n int) *http.Request

WithRetries stores the desired number of retries "n" on the given http.Request, and causes it to be retried "n" times in the case of a non-nil network related error.

Types

type Client

type Client struct {
	SSH SSHResolver

	DialTimeout         int
	KeepaliveTimeout    int
	TLSTimeout          int
	ConcurrentTransfers int
	SkipSSLVerify       bool

	Verbose          bool
	DebuggingVerbose bool
	VerboseOut       io.Writer
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx Context) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

Close closes any resources that this client opened.

func (*Client) CurrentUser

func (c *Client) CurrentUser() (string, string)

func (*Client) Do

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

Do sends an HTTP request to get an HTTP response. It wraps net/http, adding extra headers, redirection handling, and error reporting.

func (*Client) DoWithAccess

func (c *Client) DoWithAccess(req *http.Request, mode creds.AccessMode) (*http.Response, error)

DoWithAccess sends an HTTP request to get an HTTP response using the specified access mode. It wraps net/http, adding extra headers, redirection handling, and error reporting.

func (*Client) DoWithRedirect

func (c *Client) DoWithRedirect(cli *http.Client, req *http.Request, remote string, via []*http.Request) (*http.Request, *http.Response, error)

func (*Client) ExtraHeadersFor

func (c *Client) ExtraHeadersFor(req *http.Request) http.Header

func (*Client) GitEnv

func (c *Client) GitEnv() config.Environment

func (*Client) HttpClient

func (c *Client) HttpClient(u *url.URL, access creds.AccessMode) (*http.Client, error)

func (*Client) LogHTTPStats

func (c *Client) LogHTTPStats(w io.WriteCloser)

func (*Client) LogRequest

func (c *Client) LogRequest(r *http.Request, reqKey string) *http.Request

LogRequest tells the client to log the request's stats to the http log after the response body has been read.

func (*Client) LogResponse

func (c *Client) LogResponse(key string, res *http.Response)

LogResponse sends the current response stats to the http log.

DEPRECATED: Use LogRequest() instead.

func (*Client) LogStats

func (c *Client) LogStats(out io.Writer)

LogStats is intended to be called after all HTTP operations for the command have finished. It dumps k/v logs, one line per httpTransfer into a log file with the current timestamp.

DEPRECATED: Call LogHTTPStats() before the first HTTP request.

func (*Client) NewRequest

func (c *Client) NewRequest(method string, e Endpoint, suffix string, body interface{}) (*http.Request, error)

func (*Client) OSEnv

func (c *Client) OSEnv() config.Environment

func (*Client) Transport

func (c *Client) Transport(u *url.URL, access creds.AccessMode) (http.RoundTripper, error)

func (*Client) URLConfig

func (c *Client) URLConfig() *config.URLConfig

type ClientError

type ClientError struct {
	Message          string `json:"message"`
	DocumentationUrl string `json:"documentation_url,omitempty"`
	RequestId        string `json:"request_id,omitempty"`
	// contains filtered or unexported fields
}

func (*ClientError) Error

func (e *ClientError) Error() string

func (*ClientError) HTTPResponse

func (e *ClientError) HTTPResponse() *http.Response

type Context

type Context interface {
	GitConfig() *git.Configuration
	OSEnv() config.Environment
	GitEnv() config.Environment
}

func NewContext

func NewContext(gitConf *git.Configuration, osEnv, gitEnv map[string]string) Context

type Endpoint

type Endpoint struct {
	Url         string
	SSHMetadata ssh.SSHMetadata
	Operation   string
}

An Endpoint describes how to access a Git LFS server.

func EndpointFromBareSshUrl

func EndpointFromBareSshUrl(rawurl string) Endpoint

EndpointFromBareSshUrl constructs a new endpoint from a bare SSH URL:

user@host.com:path/to/repo.git or
[user@host.com:port]:path/to/repo.git

func EndpointFromFileUrl

func EndpointFromFileUrl(u *url.URL) Endpoint

Construct a new endpoint from a file URL

func EndpointFromHttpUrl

func EndpointFromHttpUrl(u *url.URL) Endpoint

Construct a new endpoint from a HTTP URL

func EndpointFromLocalPath

func EndpointFromLocalPath(path string) Endpoint

func EndpointFromSshUrl

func EndpointFromSshUrl(u *url.URL) Endpoint

EndpointFromSshUrl constructs a new endpoint from an ssh:// URL

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Seeker
	io.ReadCloser
}

func NewByteBody

func NewByteBody(by []byte) ReadSeekCloser

type SSHResolver

type SSHResolver interface {
	Resolve(Endpoint, string) (sshAuthResponse, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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