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

Method Finish

sdk/cliproxy/auth/response_model_rewriter.go:258–281  ·  view source on GitHub ↗

Finish flushes any buffered partial SSE data at the end of a stream.

()

Source from the content-addressed store, hash-verified

256
257// Finish flushes any buffered partial SSE data at the end of a stream.
258func (r *StreamRewriter) Finish() []byte {
259 if len(r.pendingBuf) == 0 {
260 return nil
261 }
262 buf := make([]byte, len(r.pendingBuf)+2)
263 copy(buf, r.pendingBuf)
264 buf[len(r.pendingBuf)] = '\n'
265 buf[len(r.pendingBuf)+1] = '\n'
266 buf = normalizeGluedSSEEvents(buf)
267 r.pendingBuf = nil
268 out := r.RewriteChunk(buf)
269 if len(r.pendingBuf) > 0 {
270 tail := rewriteSSEPayloadLines(r.pendingBuf, r.options.RewriteModel)
271 r.pendingBuf = nil
272 if len(tail) > 0 {
273 if len(out) > 0 {
274 out = append(out, tail...)
275 } else {
276 out = tail
277 }
278 }
279 }
280 return out
281}

Calls 3

RewriteChunkMethod · 0.95
normalizeGluedSSEEventsFunction · 0.85
rewriteSSEPayloadLinesFunction · 0.85