`req.getHeaders()` does not return values set using "rawHeaders" array
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
Version
v24.18.0
Platform
Darwin MBPM.local 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun 9 22:28:29 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6030 arm64
Subsystem
http
What steps will reproduce the bug?
Headers set using the message.rawHeaders format are not available on the request's getHeaders() method
import { get } from 'node:http'
const request = get(
'http://localhost:3000',
{
headers: ['foo', 'bar', 'baz', 'qux']
},
(res) => {
let data = ''
res.on('data', (chunk) => {
data += chunk
})
res.on('end', () => {
console.log(data)
})
}
)
request.on('error', () => {})
console.log(request.getHeaders()) // [Object: null prototype] {}
console.log(request.getHeaderNames()) // []
console.log(request.getRawHeaderNames()) // []
console.log(request._header) // GET / HTTP/1.1\r\nfoo: bar\r\nbaz: qux\r\nConnection: keep-alive
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
One would expect req.getHeaders() (and friends) to return a consistent value, whether an object or an array was passed as argument.
What do you see instead?
req.getHeaders() appears to be empty when request options are built using an array notation.
Additional information
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại điểm vào của request node:http và theo dõi cách mảng options.headers được lưu trữ trước khi getHeaders(), getHeaderNames() và getRawHeaderNames() được gọi. Tái hiện ví dụ, sau đó xác minh rằng các phương thức này báo cáo các header nhất quán với options ở dạng object, đồng thời giữ nguyên các header request được phát ra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- api, backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100