MCPcopy
hub / github.com/perkeep/perkeep / newRequest

Method newRequest

pkg/client/client.go:1196–1214  ·  view source on GitHub ↗

newRequest creates a request with the authentication header, and with the appropriate scheme and port in the case of self-signed TLS.

(ctx context.Context, method, url string, body ...io.Reader)

Source from the content-addressed store, hash-verified

1194// newRequest creates a request with the authentication header, and with the
1195// appropriate scheme and port in the case of self-signed TLS.
1196func (c *Client) newRequest(ctx context.Context, method, url string, body ...io.Reader) *http.Request {
1197 var bodyR io.Reader
1198 if len(body) > 0 {
1199 bodyR = body[0]
1200 }
1201 if len(body) > 1 {
1202 panic("too many body arguments")
1203 }
1204 req, err := http.NewRequest(method, url, bodyR)
1205 if err != nil {
1206 panic(err.Error())
1207 }
1208 // not done by http.NewRequest in Go 1.0:
1209 if br, ok := bodyR.(*bytes.Reader); ok {
1210 req.ContentLength = int64(br.Len())
1211 }
1212 c.authMode.AddAuthHeader(req)
1213 return req.WithContext(ctx)
1214}
1215
1216// expect2XX will doReqGated and promote HTTP response codes outside of
1217// the 200-299 range to a non-nil error containing the response body.

Callers 15

EnumerateBlobsOptsMethod · 0.95
doStatMethod · 0.95
UploadMethod · 0.95
fetchViaMethod · 0.95
GetRecentPermanodesMethod · 0.95
GetPermanodesWithAttrMethod · 0.95
DescribeMethod · 0.95
GetClaimsMethod · 0.95
queryMethod · 0.95
versionMismatchMethod · 0.95
FileHasContentsMethod · 0.95

Calls 4

NewRequestMethod · 0.80
LenMethod · 0.65
AddAuthHeaderMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected