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

Method NewHttpRequest

sdk/cliproxy/auth/conductor.go:5778–5801  ·  view source on GitHub ↗

NewHttpRequest constructs a new HTTP request and injects provider credentials into it.

(ctx context.Context, auth *Auth, method, targetURL string, body []byte, headers http.Header)

Source from the content-addressed store, hash-verified

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) {
5779 if ctx == nil {
5780 ctx = context.Background()
5781 }
5782 method = strings.TrimSpace(method)
5783 if method == "" {
5784 method = http.MethodGet
5785 }
5786 var reader io.Reader
5787 if body != nil {
5788 reader = bytes.NewReader(body)
5789 }
5790 httpReq, err := http.NewRequestWithContext(ctx, method, targetURL, reader)
5791 if err != nil {
5792 return nil, err
5793 }
5794 if headers != nil {
5795 httpReq.Header = headers.Clone()
5796 }
5797 if errPrepare := m.PrepareHttpRequest(ctx, auth, httpReq); errPrepare != nil {
5798 return nil, errPrepare
5799 }
5800 return httpReq, nil
5801}
5802
5803// HttpRequest injects provider credentials into the supplied HTTP request and executes it.
5804func (m *Manager) HttpRequest(ctx context.Context, auth *Auth, req *http.Request) (*http.Response, error) {

Callers 1

mainFunction · 0.95

Calls 2

PrepareHttpRequestMethod · 0.95
CloneMethod · 0.45

Tested by

no test coverage detected