Headers
A standard interface provided by the Fetch API for representing HTTP request and response headers. It stores key-value pairs in a normalized manner and provides access through methods such as get, set, append, and has.
Timeline (last 90 days)
The issue fixed by @ai-sdk/[email protected] is: when developers pass request headers in the form of a Headers instance, the useObject request cannot correctly preserve these headers.
Version 3.0.305 fixes the issue where useObject fails to preserve custom headers when handling request headers passed in the form of a Headers instance, corresponding to commit 2479c33.
In Web standards, request headers can be provided in the form of a plain object, an array, or a Headers instance.
The key names of the Headers interface are case-insensitive and are normalized on access, and it supports methods such as append, get, and has, and can be passed between Request and Response.
4.0.138 版本修复了 useObject 请求中 Headers 实例形式请求头丢失的问题(commit 1b5fd20),修复后普通对象和 Headers 实例两种形式都能被正确保留并透传。
健壮的处理方式是先判断类型,必要时通过 new Headers(input) 统一归一化,再逐个读取,以同时兼容对象字面量与 Headers 实例两种形式。
Headers 是 Fetch API 提供的标准接口,用于表示 HTTP 请求/响应头,内部以规范化方式存储键值对(键名统一小写、合并重复项),并通过 get、set、append、has 等方法访问,而非属性读取。
若代码用 Object.keys(headers) 或 headers[key] 的方式遍历 Headers 实例,得到的往往是空结果或错误结果。
当调用方传入 Headers 实例而被调用方按普通对象解析时,请求头会被静默丢弃,既不抛错也不告警,可能导致请求因缺少认证或追踪头而失败或行为异常。
All Facts (9)
Version 3.0.305 fixes the issue where useObject fails to preserve custom headers when handling request headers passed in the form of a Headers instance, corresponding to commit 2479c33.
50%UnverifiedIn Web standards, request headers can be provided in the form of a plain object, an array, or a Headers instance.
50%UnverifiedThe key names of the Headers interface are case-insensitive and are normalized on access, and it supports methods such as append, get, and has, and can be passed between Request and Response.
50%UnverifiedThe issue fixed by @ai-sdk/[email protected] is: when developers pass request headers in the form of a Headers instance, the useObject request cannot correctly preserve these headers.
50%Unverified4.0.138 版本修复了 useObject 请求中 Headers 实例形式请求头丢失的问题(commit 1b5fd20),修复后普通对象和 Headers 实例两种形式都能被正确保留并透传。
50%Unverified健壮的处理方式是先判断类型,必要时通过 new Headers(input) 统一归一化,再逐个读取,以同时兼容对象字面量与 Headers 实例两种形式。
50%UnverifiedHeaders 是 Fetch API 提供的标准接口,用于表示 HTTP 请求/响应头,内部以规范化方式存储键值对(键名统一小写、合并重复项),并通过 get、set、append、has 等方法访问,而非属性读取。
50%Unverified若代码用 Object.keys(headers) 或 headers[key] 的方式遍历 Headers 实例,得到的往往是空结果或错误结果。
50%Unverified当调用方传入 Headers 实例而被调用方按普通对象解析时,请求头会被静默丢弃,既不抛错也不告警,可能导致请求因缺少认证或追踪头而失败或行为异常。
50%