Skip to content

Commit 9e1c348

Browse files
committed
Use RFC-compliant HeaderValue type.
When "header-value" feature is enabled, a RFC-compliant HeaderValue type is used instead of the previously used UTF-8 String type. Since HTTP field values aren't UTF-8 encoded, using the String type meant that a plugin would crash when valid, but obsolete, non-UTF-8 characters were present in HTTP headers and/or trailers. This feature is currently optional to avoid breaking changes and to help with migration, but it will become a default feature in v0.3. The HeaderValue type is re-exported from the http crate. Signed-off-by: Piotr Sikora <[email protected]>
1 parent 6d88ed5 commit 9e1c348

File tree

18 files changed

+791
-80
lines changed

18 files changed

+791
-80
lines changed

.github/workflows/rust.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ jobs:
9494
9595
- name: Format (rules_rust)
9696
run: |
97+
sed -i'' -E 's/^default = \[\]/default = \[\"header-value\"\]/' Cargo.toml
9798
bazelisk --noworkspace_rc run --noenable_bzlmod //bazel/cargo:crates_vendor
99+
git checkout Cargo.toml
98100
git diff --exit-code
99101
100102
msrv:
@@ -148,6 +150,12 @@ jobs:
148150
- name: Clippy (wasm32-wasi)
149151
run: cargo clippy --release --all-targets --target=wasm32-wasi
150152

153+
- name: Build (header-value)
154+
run: cargo build --release --all-targets --target=wasm32-wasi --features header-value
155+
156+
- name: Clippy (header-value)
157+
run: cargo clippy --release --all-targets --target=wasm32-wasi --features header-value
158+
151159
- name: Format (rustfmt)
152160
run: cargo fmt -- --check
153161

@@ -210,6 +218,12 @@ jobs:
210218
- name: Clippy (wasm32-wasip1)
211219
run: cargo clippy --release --all-targets --target=wasm32-wasip1
212220

221+
- name: Build (header-value)
222+
run: cargo build --release --all-targets --target=wasm32-wasip1 --features header-value
223+
224+
- name: Clippy (header-value)
225+
run: cargo clippy --release --all-targets --target=wasm32-wasip1 --features header-value
226+
213227
- name: Format (rustfmt)
214228
run: cargo fmt -- --check
215229

@@ -273,6 +287,12 @@ jobs:
273287
- name: Clippy (wasm32-wasip1)
274288
run: cargo clippy --release --all-targets --target=wasm32-wasip1
275289

290+
- name: Build (header-value)
291+
run: cargo build --release --all-targets --target=wasm32-wasip1 --features header-value
292+
293+
- name: Clippy (header-value)
294+
run: cargo clippy --release --all-targets --target=wasm32-wasip1 --features header-value
295+
276296
- name: Format (rustfmt)
277297
run: cargo fmt -- --check
278298

BUILD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ rust_library(
3939
],
4040
)
4141

42+
rust_library(
43+
name = "proxy_wasm_header_value",
44+
srcs = glob(["src/*.rs"]),
45+
crate_features = ["header-value"],
46+
crate_name = "proxy_wasm",
47+
edition = "2018",
48+
visibility = ["//visibility:public"],
49+
deps = [
50+
":proxy_wasm_build_script",
51+
"//bazel/cargo/remote:hashbrown",
52+
"//bazel/cargo/remote:http",
53+
"//bazel/cargo/remote:log",
54+
],
55+
)
56+
4257
rust_binary(
4358
name = "http_auth_random",
4459
srcs = ["examples/http_auth_random/src/lib.rs"],
@@ -52,3 +67,17 @@ rust_binary(
5267
"//bazel/cargo/remote:log",
5368
],
5469
)
70+
71+
rust_binary(
72+
name = "grpc_auth_random",
73+
srcs = ["examples/grpc_auth_random/src/lib.rs"],
74+
crate_type = "cdylib",
75+
edition = "2018",
76+
out_binary = True,
77+
rustc_flags = ["-Cstrip=debuginfo"],
78+
visibility = ["//visibility:private"],
79+
deps = [
80+
":proxy_wasm_header_value",
81+
"//bazel/cargo/remote:log",
82+
],
83+
)

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ build = "build.rs"
1212

1313
[dependencies]
1414
hashbrown = "0.15"
15+
http = { version = "1", optional = true }
1516
log = "0.4"
1617

18+
[features]
19+
default = []
20+
header-value = ["dep:http"]
21+
1722
[profile.release]
1823
lto = true
1924
opt-level = 3

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
[license-badge]: https://img.shields.io/github/license/proxy-wasm/proxy-wasm-rust-sdk
1515
[license-link]: https://github.com/proxy-wasm/proxy-wasm-rust-sdk/blob/main/LICENSE
1616

17+
## Crate features
18+
19+
This crate supports the following optional features:
20+
21+
- `header-value` - uses RFC-compliant `HeaderValue` instead of UTF-8 `String` for HTTP header and trailer values.
22+
This will become the default in future releases.
23+
1724
## Examples
1825

1926
- [Hello World](./examples/hello_world/)

bazel/cargo/Cargo.Bazel.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ version = "0.2.18"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
99
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
1010

11+
[[package]]
12+
name = "bytes"
13+
version = "1.8.0"
14+
source = "registry+https://github.com/rust-lang/crates.io-index"
15+
checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
16+
1117
[[package]]
1218
name = "equivalent"
1319
version = "1.0.1"
1420
source = "registry+https://github.com/rust-lang/crates.io-index"
1521
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
1622

23+
[[package]]
24+
name = "fnv"
25+
version = "1.0.7"
26+
source = "registry+https://github.com/rust-lang/crates.io-index"
27+
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
28+
1729
[[package]]
1830
name = "foldhash"
1931
version = "0.1.3"
@@ -31,6 +43,23 @@ dependencies = [
3143
"foldhash",
3244
]
3345

46+
[[package]]
47+
name = "http"
48+
version = "1.1.0"
49+
source = "registry+https://github.com/rust-lang/crates.io-index"
50+
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
51+
dependencies = [
52+
"bytes",
53+
"fnv",
54+
"itoa",
55+
]
56+
57+
[[package]]
58+
name = "itoa"
59+
version = "1.0.11"
60+
source = "registry+https://github.com/rust-lang/crates.io-index"
61+
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
62+
3463
[[package]]
3564
name = "log"
3665
version = "0.4.22"
@@ -42,5 +71,6 @@ name = "proxy-wasm"
4271
version = "0.2.3-dev"
4372
dependencies = [
4473
"hashbrown",
74+
"http",
4575
"log",
4676
]

bazel/cargo/remote/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ alias(
3737
tags = ["manual"],
3838
)
3939

40+
alias(
41+
name = "http",
42+
actual = "@crates_vendor__http-1.1.0//:http",
43+
tags = ["manual"],
44+
)
45+
4046
alias(
4147
name = "log",
4248
actual = "@crates_vendor__log-0.4.22//:log",
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
###############################################################################
2+
# @generated
3+
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
4+
# regenerate this file, run the following:
5+
#
6+
# bazel run @//bazel/cargo:crates_vendor
7+
###############################################################################
8+
9+
load("@rules_rust//rust:defs.bzl", "rust_library")
10+
11+
package(default_visibility = ["//visibility:public"])
12+
13+
rust_library(
14+
name = "bytes",
15+
srcs = glob(
16+
include = ["**/*.rs"],
17+
allow_empty = True,
18+
),
19+
compile_data = glob(
20+
include = ["**"],
21+
allow_empty = True,
22+
exclude = [
23+
"**/* *",
24+
".tmp_git_root/**/*",
25+
"BUILD",
26+
"BUILD.bazel",
27+
"WORKSPACE",
28+
"WORKSPACE.bazel",
29+
],
30+
),
31+
crate_features = [
32+
"default",
33+
"std",
34+
],
35+
crate_root = "src/lib.rs",
36+
edition = "2018",
37+
rustc_flags = [
38+
"--cap-lints=allow",
39+
],
40+
tags = [
41+
"cargo-bazel",
42+
"crate-name=bytes",
43+
"manual",
44+
"noclippy",
45+
"norustfmt",
46+
],
47+
target_compatible_with = select({
48+
"@rules_rust//rust/platform:aarch64-apple-darwin": [],
49+
"@rules_rust//rust/platform:aarch64-apple-ios": [],
50+
"@rules_rust//rust/platform:aarch64-apple-ios-sim": [],
51+
"@rules_rust//rust/platform:aarch64-fuchsia": [],
52+
"@rules_rust//rust/platform:aarch64-linux-android": [],
53+
"@rules_rust//rust/platform:aarch64-pc-windows-msvc": [],
54+
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [],
55+
"@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [],
56+
"@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [],
57+
"@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [],
58+
"@rules_rust//rust/platform:armv7-linux-androideabi": [],
59+
"@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [],
60+
"@rules_rust//rust/platform:i686-apple-darwin": [],
61+
"@rules_rust//rust/platform:i686-linux-android": [],
62+
"@rules_rust//rust/platform:i686-pc-windows-msvc": [],
63+
"@rules_rust//rust/platform:i686-unknown-freebsd": [],
64+
"@rules_rust//rust/platform:i686-unknown-linux-gnu": [],
65+
"@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [],
66+
"@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [],
67+
"@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [],
68+
"@rules_rust//rust/platform:s390x-unknown-linux-gnu": [],
69+
"@rules_rust//rust/platform:thumbv7em-none-eabi": [],
70+
"@rules_rust//rust/platform:thumbv8m.main-none-eabi": [],
71+
"@rules_rust//rust/platform:wasm32-unknown-unknown": [],
72+
"@rules_rust//rust/platform:wasm32-wasi": [],
73+
"@rules_rust//rust/platform:x86_64-apple-darwin": [],
74+
"@rules_rust//rust/platform:x86_64-apple-ios": [],
75+
"@rules_rust//rust/platform:x86_64-fuchsia": [],
76+
"@rules_rust//rust/platform:x86_64-linux-android": [],
77+
"@rules_rust//rust/platform:x86_64-pc-windows-msvc": [],
78+
"@rules_rust//rust/platform:x86_64-unknown-freebsd": [],
79+
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [],
80+
"@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [],
81+
"@rules_rust//rust/platform:x86_64-unknown-none": [],
82+
"//conditions:default": ["@platforms//:incompatible"],
83+
}),
84+
version = "1.8.0",
85+
)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
###############################################################################
2+
# @generated
3+
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
4+
# regenerate this file, run the following:
5+
#
6+
# bazel run @//bazel/cargo:crates_vendor
7+
###############################################################################
8+
9+
load("@rules_rust//rust:defs.bzl", "rust_library")
10+
11+
package(default_visibility = ["//visibility:public"])
12+
13+
rust_library(
14+
name = "fnv",
15+
srcs = glob(
16+
include = ["**/*.rs"],
17+
allow_empty = True,
18+
),
19+
compile_data = glob(
20+
include = ["**"],
21+
allow_empty = True,
22+
exclude = [
23+
"**/* *",
24+
".tmp_git_root/**/*",
25+
"BUILD",
26+
"BUILD.bazel",
27+
"WORKSPACE",
28+
"WORKSPACE.bazel",
29+
],
30+
),
31+
crate_features = [
32+
"default",
33+
"std",
34+
],
35+
crate_root = "lib.rs",
36+
edition = "2015",
37+
rustc_flags = [
38+
"--cap-lints=allow",
39+
],
40+
tags = [
41+
"cargo-bazel",
42+
"crate-name=fnv",
43+
"manual",
44+
"noclippy",
45+
"norustfmt",
46+
],
47+
target_compatible_with = select({
48+
"@rules_rust//rust/platform:aarch64-apple-darwin": [],
49+
"@rules_rust//rust/platform:aarch64-apple-ios": [],
50+
"@rules_rust//rust/platform:aarch64-apple-ios-sim": [],
51+
"@rules_rust//rust/platform:aarch64-fuchsia": [],
52+
"@rules_rust//rust/platform:aarch64-linux-android": [],
53+
"@rules_rust//rust/platform:aarch64-pc-windows-msvc": [],
54+
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [],
55+
"@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [],
56+
"@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [],
57+
"@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [],
58+
"@rules_rust//rust/platform:armv7-linux-androideabi": [],
59+
"@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [],
60+
"@rules_rust//rust/platform:i686-apple-darwin": [],
61+
"@rules_rust//rust/platform:i686-linux-android": [],
62+
"@rules_rust//rust/platform:i686-pc-windows-msvc": [],
63+
"@rules_rust//rust/platform:i686-unknown-freebsd": [],
64+
"@rules_rust//rust/platform:i686-unknown-linux-gnu": [],
65+
"@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [],
66+
"@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [],
67+
"@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [],
68+
"@rules_rust//rust/platform:s390x-unknown-linux-gnu": [],
69+
"@rules_rust//rust/platform:thumbv7em-none-eabi": [],
70+
"@rules_rust//rust/platform:thumbv8m.main-none-eabi": [],
71+
"@rules_rust//rust/platform:wasm32-unknown-unknown": [],
72+
"@rules_rust//rust/platform:wasm32-wasi": [],
73+
"@rules_rust//rust/platform:x86_64-apple-darwin": [],
74+
"@rules_rust//rust/platform:x86_64-apple-ios": [],
75+
"@rules_rust//rust/platform:x86_64-fuchsia": [],
76+
"@rules_rust//rust/platform:x86_64-linux-android": [],
77+
"@rules_rust//rust/platform:x86_64-pc-windows-msvc": [],
78+
"@rules_rust//rust/platform:x86_64-unknown-freebsd": [],
79+
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [],
80+
"@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [],
81+
"@rules_rust//rust/platform:x86_64-unknown-none": [],
82+
"//conditions:default": ["@platforms//:incompatible"],
83+
}),
84+
version = "1.0.7",
85+
)

0 commit comments

Comments
 (0)