MCPcopy
hub / github.com/git-lfs/git-lfs / DoWithAuth

Method DoWithAuth

lfsapi/auth.go:26–43  ·  view source on GitHub ↗

DoWithAuth sends an HTTP request to get an HTTP response. It attempts to add authentication from netrc or git's credential helpers if necessary, supporting basic authentication.

(remote string, access creds.Access, req *http.Request)

Source from the content-addressed store, hash-verified

24// authentication from netrc or git's credential helpers if necessary,
25// supporting basic authentication.
26func (c *Client) DoWithAuth(remote string, access creds.Access, req *http.Request) (*http.Response, error) {
27 count := 0
28 res, err := c.doWithAuth(remote, &count, access, req, nil)
29
30 if errors.IsAuthError(err) {
31 if len(req.Header.Get("Authorization")) == 0 {
32 // This case represents a rejected request that
33 // should have been authenticated but wasn't. Do
34 // not count this against our redirection
35 // maximum.
36 newAccess := c.Endpoints.AccessFor(access.URL())
37 tracerx.Printf("api: http response indicates %q authentication. Resubmitting...", newAccess.Mode())
38 return c.DoWithAuth(remote, newAccess, req)
39 }
40 }
41
42 return res, err
43}
44
45// DoWithAuthNoRetry sends an HTTP request to get an HTTP response. It works in
46// the same way as DoWithAuth, but will not retry the request if it fails with

Callers 4

DoAPIRequestWithAuthMethod · 0.95
TestDoWithAuthApproveFunction · 0.95
TestDoWithAuthRejectFunction · 0.95
verifyUploadFunction · 0.80

Calls 6

doWithAuthMethod · 0.95
IsAuthErrorFunction · 0.92
URLMethod · 0.80
ModeMethod · 0.80
GetMethod · 0.65
AccessForMethod · 0.65

Tested by 2

TestDoWithAuthApproveFunction · 0.76
TestDoWithAuthRejectFunction · 0.76