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

Method PrepareHttpRequest

sdk/cliproxy/auth/conductor.go:5749–5775  ·  view source on GitHub ↗

PrepareHttpRequest injects provider credentials into the supplied HTTP request.

(ctx context.Context, auth *Auth, req *http.Request)

Source from the content-addressed store, hash-verified

5747
5748// PrepareHttpRequest injects provider credentials into the supplied HTTP request.
5749func (m *Manager) PrepareHttpRequest(ctx context.Context, auth *Auth, req *http.Request) error {
5750 if m == nil {
5751 return &Error{Code: "provider_not_found", Message: "manager is nil"}
5752 }
5753 if auth == nil {
5754 return &Error{Code: "auth_not_found", Message: "auth is nil"}
5755 }
5756 if req == nil {
5757 return &Error{Code: "invalid_request", Message: "http request is nil"}
5758 }
5759 if ctx != nil {
5760 *req = *req.WithContext(ctx)
5761 }
5762 providerKey := executorKeyFromAuth(auth)
5763 if providerKey == "" {
5764 return &Error{Code: "provider_not_found", Message: "auth provider is empty"}
5765 }
5766 exec := m.executorFor(providerKey)
5767 if exec == nil {
5768 return &Error{Code: "provider_not_found", Message: "executor not registered for provider: " + providerKey}
5769 }
5770 preparer, ok := exec.(RequestPreparer)
5771 if !ok || preparer == nil {
5772 return &Error{Code: "not_supported", Message: "executor does not support http request preparation"}
5773 }
5774 return preparer.PrepareRequest(req, auth)
5775}
5776
5777// NewHttpRequest constructs a new HTTP request and injects provider credentials into it.
5778func (m *Manager) NewHttpRequest(ctx context.Context, auth *Auth, method, targetURL string, body []byte, headers http.Header) (*http.Request, error) {

Callers 1

NewHttpRequestMethod · 0.95

Calls 3

executorForMethod · 0.95
executorKeyFromAuthFunction · 0.85
PrepareRequestMethod · 0.65

Tested by

no test coverage detected