MCPcopy
hub / github.com/mudler/LocalAI / Write

Method Write

core/http/middleware/trace.go:81–99  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

79}
80
81func (w *bodyWriter) Write(b []byte) (int, error) {
82 // Capture into the trace buffer up to maxBytes, then drop the overflow
83 // so a chatty endpoint can't grow the buffer without bound. The full
84 // payload still flows through to the real client below.
85 w.totalBytes += len(b)
86 if w.maxBytes <= 0 {
87 w.body.Write(b)
88 } else if remain := w.maxBytes - w.body.Len(); remain > 0 {
89 if remain >= len(b) {
90 w.body.Write(b)
91 } else {
92 w.body.Write(b[:remain])
93 w.truncated = true
94 }
95 } else {
96 w.truncated = true
97 }
98 return w.ResponseWriter.Write(b)
99}
100
101func (w *bodyWriter) Flush() {
102 if flusher, ok := w.ResponseWriter.(http.Flusher); ok {

Callers 15

routerConfigFingerprintFunction · 0.45
HashAPIKeyFunction · 0.45
makeMultipartRequestFunction · 0.45
processImageFileFunction · 0.45
writeWindowWAVFunction · 0.45
writeUtteranceWAVFunction · 0.45
InpaintingEndpointFunction · 0.45
TTSEndpointFunction · 0.45

Calls 1

LenMethod · 0.45

Tested by 3

makeMultipartRequestFunction · 0.36
multipartFileFunction · 0.36
writeTestGGUFFunction · 0.36