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

Function passthroughError

core/services/cloudproxy/proxy.go:42–51  ·  view source on GitHub ↗

passthroughError emits the upstream's error response unchanged.

(c echo.Context, statusCode int, contentType string, body io.Reader)

Source from the content-addressed store, hash-verified

40
41// passthroughError emits the upstream's error response unchanged.
42func passthroughError(c echo.Context, statusCode int, contentType string, body io.Reader) error {
43 const maxErrBody = 1 << 20
44 buf, _ := io.ReadAll(io.LimitReader(body, maxErrBody))
45 if contentType != "" {
46 c.Response().Header().Set("Content-Type", contentType)
47 }
48 c.Response().WriteHeader(statusCode)
49 _, _ = c.Response().Writer.Write(buf)
50 return nil
51}
52
53func forwardBuffered(c echo.Context, statusCode int, contentType string, body io.Reader) error {
54 if contentType != "" {

Callers 1

ForwardViaBackendFunction · 0.85

Calls 4

HeaderMethod · 0.80
SetMethod · 0.65
WriteHeaderMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected