Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add Option<&'static [u8]> method for header names

Đang mở
#611 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách xác định biểu diễn tên header và phương thức as_bytes hiện có của nó, sau đó kiểm tra cách các tên header tiêu chuẩn được nhận diện. Thêm phương thức được đề xuất để các tên ASCII tiêu chuẩn có thể cung cấp các byte tĩnh, còn những tên khác trả về None, đồng thời thêm các bài kiểm thử bao quát cả hai trường hợp. Issue không đề cập đến tệp hoặc đường dẫn kiểm thử cụ thể nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

This enhancement focuses on improving the usability of the http crate when integrating Rust HTTP libraries with other VM engines, such as V8 (specifically for, but not limited to Deno). The goal is to provide embedding users with a specific method that allows extracting a static 7-bit string from a well-known ASCII header name. By treating header strings as interned strings in scripting engines [1] [2], we can effectively reduce garbage collection pressure, leading to enhanced performance and efficiency.

To achieve this, we propose introducing an Option<&'static [u8]> method for header names. This approach offers a more efficient means of passing header names across embedding boundaries. When working with static ASCII header names, this method allows direct access to the header name bytes across embedding boundaries, without the need for additional memory allocation or garbage collection overhead.

This may also be useful for Python embedders [2], as (I believe) the CPython engine allows creation of strings from const 1-byte buffers.

Alternatives

While we do have an as_bytes method on a header name, this does not tell us the provenance of those bytes, and whether the header is a StandardHeader. We cannot use these as "externally interned" strings in an embedding context because they may be allocated.

The hash function of the header could be used allow us to map between standard headers and interned strings in the embedded engine, but this requires an additional string comparison operation.

References

[1] V8's NewExternalOneByte method:

https://v8docs.nodesource.com/node-15.0/d2/db3/classv8_1_1_string.html#a2b9afa662981b864fdadbc4fe1eb7480

[2] Python's PyUnicode_FromKindAndData method (which I believe will avoid copies where necessary):

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_FromKindAndData

Ngôn ngữ chính
Rust
Star
1.4k
Fork
385
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của hyperium/http

Tất cả issue của hyperium/http

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.