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

Method Do

internal/pluginhost/http_bridge.go:31–58  ·  view source on GitHub ↗
(ctx context.Context, req pluginapi.HTTPRequest)

Source from the content-addressed store, hash-verified

29}
30
31func (c *hostHTTPClient) Do(ctx context.Context, req pluginapi.HTTPRequest) (pluginapi.HTTPResponse, error) {
32 if ctx == nil {
33 ctx = context.Background()
34 }
35 resp, cfg, errDo := c.doHTTP(ctx, req)
36 if errDo != nil {
37 return pluginapi.HTTPResponse{}, errDo
38 }
39 defer func() {
40 if errClose := resp.Body.Close(); errClose != nil {
41 log.Warnf("pluginhost: response body close error: %v", errClose)
42 }
43 }()
44 helps.RecordAPIResponseMetadata(ctx, cfg, resp.StatusCode, resp.Header.Clone())
45 body, errReadAll := io.ReadAll(resp.Body)
46 if len(body) > 0 {
47 helps.AppendAPIResponseChunk(ctx, cfg, body)
48 }
49 if errReadAll != nil {
50 helps.RecordAPIResponseError(ctx, cfg, errReadAll)
51 return pluginapi.HTTPResponse{}, fmt.Errorf("read host http response: %w", errReadAll)
52 }
53 return pluginapi.HTTPResponse{
54 StatusCode: resp.StatusCode,
55 Headers: cloneHeader(resp.Header),
56 Body: body,
57 }, nil
58}
59
60func (c *hostHTTPClient) DoStream(ctx context.Context, req pluginapi.HTTPRequest) (pluginapi.HTTPStreamResponse, error) {
61 if ctx == nil {

Callers

nothing calls this directly

Calls 7

doHTTPMethod · 0.95
AppendAPIResponseChunkFunction · 0.92
RecordAPIResponseErrorFunction · 0.92
cloneHeaderFunction · 0.70
CloseMethod · 0.65
CloneMethod · 0.45

Tested by

no test coverage detected