Files
LocalAI/core/http
Ettore Di Giacinto 42d6e52fd7 refactor(openai): drop MaybeSetNodeHeaderForTest shim, move test internal
The exported MaybeSetNodeHeaderForTest wrapper existed solely so the
node_header_test.go file could live in package openai_test. That
polluted the public API with a test-only shim. Move the test into
package openai (internal test) and call maybeSetNodeHeader directly.

Also drop the dead nodeIDContextKey constant and the c.Set(...) that
wrote to it: nothing in the tree ever read it back. The streaming
header fix uses a per-request chan instead of an Echo context value,
since a context value would not survive across the request goroutine
and worker goroutine boundary cleanly without extra synchronization.
Refresh the maybeSetNodeHeader comment to spell out that streaming
callers must NOT invoke it from the request goroutine before the
worker is launched - that ordering is exactly the bug the streaming
fix addresses.

Add a helper resolveNodeID that returns the node ID string (without
touching the response writer) so the streaming workers can share the
"opt-in + loaded + has node ID" gating with the buffered handlers
without duplicating the check.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-7[1m]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-05-24 20:47:43 +00:00
..
2026-03-30 00:47:27 +02:00