MCPcopy
hub / github.com/autobrr/qui / applyAuthHeaders

Method applyAuthHeaders

internal/proxy/handler.go:521–548  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

519}
520
521func (pc *proxyContext) applyAuthHeaders(req *http.Request) {
522 if pc == nil || req == nil {
523 return
524 }
525
526 if pc.httpClient != nil && pc.httpClient.Jar != nil && pc.instanceURL != nil {
527 cookies := pc.httpClient.Jar.Cookies(pc.instanceURL)
528 if len(cookies) > 0 {
529 var cookiePairs []string
530 for _, cookie := range cookies {
531 cookiePairs = append(cookiePairs, fmt.Sprintf("%s=%s", cookie.Name, cookie.Value))
532 }
533 req.Header.Set("Cookie", strings.Join(cookiePairs, "; "))
534 } else {
535 req.Header.Del("Cookie")
536 }
537 }
538
539 if pc.basicAuth != nil {
540 req.SetBasicAuth(pc.basicAuth.username, pc.basicAuth.password)
541 } else {
542 req.Header.Del("Authorization")
543 }
544
545 if pc.apiKey != "" {
546 req.Header.Set("Authorization", "Bearer "+pc.apiKey)
547 }
548}
549
550func (pc *proxyContext) refreshSession(ctx context.Context) error {
551 if pc == nil || pc.session == nil {

Callers 3

rewriteRequestMethod · 0.80
RoundTripMethod · 0.80

Calls 1

SetMethod · 0.45

Tested by 1