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/vue@2.0.275 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 is a standard interface provided by the Fetch API for representing HTTP request/response headers; it internally stores key-value pairs in a normalized manner (keys uniformly lowercased, duplicates merged), and is accessed through methods such as get, set, append, and has rather than property reads.
若代码用 Object.keys(headers) 或 headers[key] 的方式遍历 Headers 实例,得到的往往是空结果或错误结果。
当调用方传入 Headers 实例而被调用方按普通对象解析时,请求头会被静默丢弃,既不抛错也不告警,可能导致请求因缺少认证或追踪头而失败或行为异常。
All Facts (9)
Headers is a standard interface provided by the Fetch API for representing HTTP request/response headers; it internally stores key-value pairs in a normalized manner (keys uniformly lowercased, duplicates merged), and is accessed through methods such as get, set, append, and has rather than property reads.
70%UnverifiedVersion 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/vue@2.0.275 is: when developers pass request headers in the form of a Headers instance, the useObject request cannot correctly preserve these headers.
50%Unverified健壮的处理方式是先判断类型,必要时通过 new Headers(input) 统一归一化,再逐个读取,以同时兼容对象字面量与 Headers 实例两种形式。
50%Unverified若代码用 Object.keys(headers) 或 headers[key] 的方式遍历 Headers 实例,得到的往往是空结果或错误结果。
50%Unverified当调用方传入 Headers 实例而被调用方按普通对象解析时,请求头会被静默丢弃,既不抛错也不告警,可能导致请求因缺少认证或追踪头而失败或行为异常。
50%Unverified4.0.138 版本修复了 useObject 请求中 Headers 实例形式请求头丢失的问题(commit 1b5fd20),修复后普通对象和 Headers 实例两种形式都能被正确保留并透传。
50%