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

Method callHostHTTPStreamRead

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

Source from the content-addressed store, hash-verified

183}
184
185func (h *Host) callHostHTTPStreamRead(ctx context.Context, request []byte) ([]byte, error) {
186 var req rpcHostHTTPStreamReadRequest
187 if errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {
188 return nil, fmt.Errorf("decode host http stream read request: %w", errUnmarshal)
189 }
190 if h == nil || h.httpStreams == nil {
191 return nil, fmt.Errorf("host http stream bridge is unavailable")
192 }
193 chunk, done, errRead := h.httpStreams.read(ctx, req.StreamID)
194 if errRead != nil {
195 return nil, errRead
196 }
197 resp := rpcHostHTTPStreamReadResponse{
198 Payload: append([]byte(nil), chunk.Payload...),
199 Done: done,
200 }
201 if chunk.Err != nil {
202 resp.Error = chunk.Err.Error()
203 resp.Done = true
204 }
205 return marshalRPCResult(resp)
206}
207
208func (h *Host) callHostHTTPStreamClose(request []byte) ([]byte, error) {
209 var req rpcHostHTTPStreamCloseRequest

Callers 1

callFromPluginMethod · 0.95

Calls 3

marshalRPCResultFunction · 0.85
readMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected