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

Method callHostHTTPDoStream

internal/pluginhost/host_callbacks.go:155–183  ·  view source on GitHub ↗
(ctx context.Context, request []byte)

Source from the content-addressed store, hash-verified

153}
154
155func (h *Host) callHostHTTPDoStream(ctx context.Context, request []byte) ([]byte, error) {
156 httpReq, callbackID, errDecode := decodeHostHTTPRequestWithCallbackID(request)
157 if errDecode != nil {
158 return nil, errDecode
159 }
160 ctx = h.resolveCallbackContext(callbackID, ctx)
161 if ctx == nil {
162 ctx = context.Background()
163 }
164 streamCtx, cancel := context.WithCancel(ctx)
165 resp, errDo := h.newHTTPClient(nil).DoStream(streamCtx, httpReq)
166 if errDo != nil {
167 cancel()
168 return nil, errDo
169 }
170 streamID := ""
171 if h != nil && h.httpStreams != nil {
172 streamID = h.httpStreams.open(resp.Chunks, cancel)
173 }
174 if streamID == "" {
175 cancel()
176 return nil, fmt.Errorf("host http stream bridge is unavailable")
177 }
178 return marshalRPCResult(rpcHostHTTPStreamResponse{
179 StatusCode: resp.StatusCode,
180 Headers: httpHeader(resp.Headers),
181 StreamID: streamID,
182 })
183}
184
185func (h *Host) callHostHTTPStreamRead(ctx context.Context, request []byte) ([]byte, error) {
186 var req rpcHostHTTPStreamReadRequest

Callers 1

callFromPluginMethod · 0.95

Calls 7

newHTTPClientMethod · 0.95
marshalRPCResultFunction · 0.85
httpHeaderTypeAlias · 0.85
DoStreamMethod · 0.65
openMethod · 0.45

Tested by

no test coverage detected