mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 12:11:34 +00:00
20 lines
751 B
TypeScript
20 lines
751 B
TypeScript
// Voice Call plugin module implements http headers behavior.
|
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
|
|
// Case-insensitive HTTP header lookup for provider webhook handlers.
|
|
|
|
type HttpHeaderMap = Record<string, string | string[] | undefined>;
|
|
|
|
/** Return the first value for a header name regardless of caller casing. */
|
|
export function getHeader(headers: HttpHeaderMap, name: string): string | undefined {
|
|
const target = normalizeLowercaseStringOrEmpty(name);
|
|
const direct = headers[target];
|
|
const value =
|
|
direct ??
|
|
Object.entries(headers).find(([key]) => normalizeLowercaseStringOrEmpty(key) === target)?.[1];
|
|
if (Array.isArray(value)) {
|
|
return value[0];
|
|
}
|
|
return value;
|
|
}
|