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

Method newHTTPRequest

tq/adapterbase.go:202–225  ·  view source on GitHub ↗
(method string, rel *Action)

Source from the content-addressed store, hash-verified

200var httpRE = regexp.MustCompile(`\Ahttps?://`)
201
202func (a *adapterBase) newHTTPRequest(method string, rel *Action) (*http.Request, error) {
203 enableRewrite := a.apiClient.GitEnv().Bool(enableHrefRewriteKey, defaultEnableHrefRewrite)
204
205 href := rel.Href
206 if enableRewrite {
207 href = a.apiClient.Endpoints.NewEndpoint(a.direction.String(), rel.Href).Url
208 }
209
210 if !httpRE.MatchString(href) {
211 urlfragment := strings.SplitN(href, "?", 2)[0]
212 return nil, errors.New(tr.Tr.Get("missing protocol: %q", urlfragment))
213 }
214
215 req, err := http.NewRequest(method, href, nil)
216 if err != nil {
217 return nil, err
218 }
219
220 for key, value := range rel.Header {
221 req.Header.Set(key, value)
222 }
223
224 return req, nil
225}
226
227func (a *adapterBase) doHTTP(t *Transfer, req *http.Request) (*http.Response, error) {
228 if t.Authenticated {

Callers 3

DoTransferMethod · 0.80
downloadMethod · 0.80
DoTransferMethod · 0.80

Calls 8

NewFunction · 0.92
BoolMethod · 0.65
GitEnvMethod · 0.65
NewEndpointMethod · 0.65
StringMethod · 0.65
GetMethod · 0.65
SetMethod · 0.65
NewRequestMethod · 0.45

Tested by

no test coverage detected