MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / applyRequestAfterAuthInterceptor

Function applyRequestAfterAuthInterceptor

sdk/cliproxy/auth/conductor.go:2383–2404  ·  view source on GitHub ↗
(ctx context.Context, executor ProviderExecutor, provider string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options, requestedModel string)

Source from the content-addressed store, hash-verified

2381}
2382
2383func applyRequestAfterAuthInterceptor(ctx context.Context, executor ProviderExecutor, provider string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options, requestedModel string) (cliproxyexecutor.Request, cliproxyexecutor.Options) {
2384 if opts.RequestAfterAuthInterceptor == nil {
2385 return req, opts
2386 }
2387 toFormat := requestToFormat(provider, executor, req, opts)
2388 resp := opts.RequestAfterAuthInterceptor(ctx, cliproxyexecutor.RequestAfterAuthInterceptRequest{
2389 SourceFormat: opts.SourceFormat,
2390 ToFormat: toFormat,
2391 Model: req.Model,
2392 RequestedModel: requestedModel,
2393 Stream: opts.Stream,
2394 Headers: cloneRequestHeaders(opts.Headers),
2395 Body: bytes.Clone(req.Payload),
2396 Metadata: opts.Metadata,
2397 })
2398 opts.Headers = mergeRequestHeaders(opts.Headers, resp.Headers, resp.ClearHeaders)
2399 if len(resp.Body) > 0 {
2400 req.Payload = bytes.Clone(resp.Body)
2401 opts.OriginalRequest = bytes.Clone(resp.Body)
2402 }
2403 return req, opts
2404}
2405
2406func requestToFormat(provider string, executor ProviderExecutor, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) sdktranslator.Format {
2407 resolver, ok := executor.(requestToFormatResolver)

Callers 3

executeMixedOnceMethod · 0.85
executeCountMixedOnceMethod · 0.85

Calls 4

requestToFormatFunction · 0.85
cloneRequestHeadersFunction · 0.85
mergeRequestHeadersFunction · 0.85
CloneMethod · 0.45

Tested by

no test coverage detected