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

Function extractSSEJSON

internal/toolinjection/inject_stream.go:331–343  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Common helpers --------------------------------------------------------------------------- extractSSEJSON extracts the JSON payload from an SSE data line within a chunk.

(chunk []byte)

Source from the content-addressed store, hash-verified

329
330// extractSSEJSON extracts the JSON payload from an SSE data line within a chunk.
331func extractSSEJSON(chunk []byte) []byte {
332 for _, line := range bytes.Split(chunk, []byte("\n")) {
333 line = bytes.TrimSpace(line)
334 if bytes.HasPrefix(line, []byte("data:")) {
335 data := bytes.TrimPrefix(line, []byte("data:"))
336 data = bytes.TrimSpace(data)
337 if len(data) > 0 && data[0] == '{' {
338 return data
339 }
340 }
341 }
342 return nil
343}
344
345// sseJSONReplace applies a transform function to the JSON payload inside an SSE
346// data line, returning the chunk with the modified JSON.

Callers 5

InjectClaudeStreamFunction · 0.85
isClaudeMessageDeltaFunction · 0.85
InjectResponsesStreamFunction · 0.85
isResponsesCompletedFunction · 0.85

Calls

no outgoing calls

Tested by 1