MCPcopy Index your code
hub / github.com/chainreactors/EvilProxy / HttpRequest

Method HttpRequest

internal/pluginhost/adapters.go:1745–1790  ·  view source on GitHub ↗
(ctx context.Context, auth *coreauth.Auth, req *http.Request)

Source from the content-addressed store, hash-verified

1743}
1744
1745func (a *executorAdapter) HttpRequest(ctx context.Context, auth *coreauth.Auth, req *http.Request) (resp *http.Response, err error) {
1746 if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) {
1747 return nil, fmt.Errorf("plugin executor %s is unavailable", a.Identifier())
1748 }
1749 if req == nil {
1750 return nil, fmt.Errorf("plugin executor %s received nil HTTP request", a.Identifier())
1751 }
1752 defer func() {
1753 if recovered := recover(); recovered != nil {
1754 a.host.fusePlugin(a.pluginID, "Executor.HttpRequest", recovered)
1755 resp = nil
1756 err = fmt.Errorf("plugin executor %s http request panic: %v", a.Identifier(), recovered)
1757 }
1758 }()
1759 body, errReadAll := readAndRestoreRequestBody(req)
1760 if errReadAll != nil {
1761 return nil, fmt.Errorf("read plugin http request body: %w", errReadAll)
1762 }
1763 pluginResp, errHTTPRequest := a.executor.HttpRequest(ctx, pluginapi.ExecutorHTTPRequest{
1764 AuthID: authID(auth),
1765 AuthProvider: authProvider(auth),
1766 Method: req.Method,
1767 URL: req.URL.String(),
1768 Headers: cloneHeader(req.Header),
1769 Body: bytes.Clone(body),
1770 StorageJSON: storageJSONFromAuth(auth),
1771 Metadata: cloneAnyMap(authMetadata(auth)),
1772 Attributes: authAttributes(auth),
1773 HTTPClient: a.host.newHTTPClient(auth, a.provider),
1774 })
1775 if errHTTPRequest != nil {
1776 return nil, errHTTPRequest
1777 }
1778 status := pluginResp.StatusCode
1779 if status == 0 {
1780 status = http.StatusOK
1781 }
1782 resp = &http.Response{
1783 StatusCode: status,
1784 Status: fmt.Sprintf("%d %s", status, http.StatusText(status)),
1785 Header: cloneHeader(pluginResp.Headers),
1786 Body: io.NopCloser(bytes.NewReader(bytes.Clone(pluginResp.Body))),
1787 Request: req,
1788 }
1789 return resp, nil
1790}
1791
1792type usageAdapter struct {
1793 host *Host

Callers

nothing calls this directly

Calls 15

IdentifierMethod · 0.95
authIDFunction · 0.85
authProviderFunction · 0.85
storageJSONFromAuthFunction · 0.85
cloneAnyMapFunction · 0.85
authMetadataFunction · 0.85
isPluginFusedMethod · 0.80
pluginIdentityCurrentMethod · 0.80
fusePluginMethod · 0.80
newHTTPClientMethod · 0.80
cloneHeaderFunction · 0.70

Tested by

no test coverage detected