MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / doHTTPAuthRequest

Function doHTTPAuthRequest

rest/server_context.go:2105–2126  ·  view source on GitHub ↗
(ctx context.Context, httpClient *http.Client, username, password, method, path string, endpoints []string, requestBody []byte)

Source from the content-addressed store, hash-verified

2103}
2104
2105func doHTTPAuthRequest(ctx context.Context, httpClient *http.Client, username, password, method, path string, endpoints []string, requestBody []byte) (statusCode int, responseBody []byte, err error) {
2106 retryCount := 0
2107
2108 worker := func() (shouldRetry bool, err error, value interface{}) {
2109 endpointIdx := retryCount % len(endpoints)
2110 responseBody, statusCode, err = base.MgmtRequest(httpClient, endpoints[endpointIdx], method, path, "", username, password, bytes.NewBuffer(requestBody))
2111
2112 if err, ok := err.(net.Error); ok && err.Timeout() {
2113 retryCount++
2114 return true, err, nil
2115 }
2116
2117 return false, err, nil
2118 }
2119
2120 err, _ = base.RetryLoop(ctx, "doHTTPAuthRequest", worker, base.CreateSleeperFunc(10, 100))
2121 if err != nil {
2122 return 0, nil, err
2123 }
2124
2125 return statusCode, responseBody, nil
2126}
2127
2128// For test use
2129func (sc *ServerContext) Database(ctx context.Context, name string) *db.DatabaseContext {

Callers 4

CheckPermissionsFunction · 0.85
cbRBACWhoAmIFunction · 0.85
getClusterUUIDMethod · 0.85

Calls 3

MgmtRequestFunction · 0.92
RetryLoopFunction · 0.92
CreateSleeperFuncFunction · 0.92

Tested by

no test coverage detected