itsi 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c1c81086711872c2ceaa5042078e05f4da5b6f4246bf6d5bc24ff607581557
4
- data.tar.gz: 551e582ba837c8a4fe19a09ced2f38866493be737e6ac5188d206fad4835a510
3
+ metadata.gz: 48a2f9ed6dbf64c922c0afd1a8f7ecd07fbed9587b6863cd3052eb1b957d00da
4
+ data.tar.gz: c69b07d771b76e228213f251e77170ce20b81c169327781865d4f03a865e934b
5
5
  SHA512:
6
- metadata.gz: 5e858281765fdc2c698d2af7ec7e5c05efbda0430cc49ca0319acd23bdc7f35b12d72a5496fbac6c3cbd1d594f46dfb16bf5daac2fded466be9ede98d3cecca5
7
- data.tar.gz: e28a5fa4d4c3c6b2b2169005f0d686d90f2bf9c1b98f02bc7dd283189e26ad09698d519a7879280724b49e2794c994872b7c3cba5927dcdcf974d6b762f24164
6
+ metadata.gz: 9f99f959ffa9090035849acd0433d9117ca73d2565d2eb0d656a2b6f2dbc2dbfcef32b27a2c2ab2c20f143faca27a6c96df000046659d36d54ab0cfd43fcb690
7
+ data.tar.gz: af9a7f471ee483dcb28b6a3c1520b7a050423427f2b1219308f64ee2a12dfe862de61eb46688ae0accf2fc634c65a01e393a3f3f5044476a124541b0d0a9b453
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.2.14] - 2025-04-30
2
+ - Support new-line separated headers for Rack 2 backward compatibility.
3
+
4
+ ## [0.2.12] - 2025-04-29
5
+ - Max Rust edition is now "2021"
6
+ - Removed invalid rbs files causing RI doc generation failure
7
+ - Fixed header clobbering in Rack
8
+ - Added new `ruby_thread_request_backlog_size` option
9
+
1
10
  ## [0.2.3] - 2025-04-22
2
11
 
3
12
  - Public release!
data/Cargo.lock CHANGED
@@ -17,6 +17,19 @@ version = "2.0.0"
17
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
18
18
  checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
19
19
 
20
+ [[package]]
21
+ name = "ahash"
22
+ version = "0.8.11"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
25
+ dependencies = [
26
+ "cfg-if",
27
+ "getrandom 0.2.15",
28
+ "once_cell",
29
+ "version_check",
30
+ "zerocopy 0.7.35",
31
+ ]
32
+
20
33
  [[package]]
21
34
  name = "aho-corasick"
22
35
  version = "1.1.3"
@@ -1080,19 +1093,6 @@ dependencies = [
1080
1093
  "slab",
1081
1094
  ]
1082
1095
 
1083
- [[package]]
1084
- name = "generator"
1085
- version = "0.8.4"
1086
- source = "registry+https://github.com/rust-lang/crates.io-index"
1087
- checksum = "cc6bd114ceda131d3b1d665eba35788690ad37f5916457286b32ab6fd3c438dd"
1088
- dependencies = [
1089
- "cfg-if",
1090
- "libc",
1091
- "log",
1092
- "rustversion",
1093
- "windows 0.58.0",
1094
- ]
1095
-
1096
1096
  [[package]]
1097
1097
  name = "generic-array"
1098
1098
  version = "0.14.7"
@@ -1644,7 +1644,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
1644
1644
 
1645
1645
  [[package]]
1646
1646
  name = "itsi-scheduler"
1647
- version = "0.2.13"
1647
+ version = "0.2.15"
1648
1648
  dependencies = [
1649
1649
  "bytes",
1650
1650
  "derive_more",
@@ -1662,7 +1662,7 @@ dependencies = [
1662
1662
 
1663
1663
  [[package]]
1664
1664
  name = "itsi-server"
1665
- version = "0.2.13"
1665
+ version = "0.2.15"
1666
1666
  dependencies = [
1667
1667
  "argon2",
1668
1668
  "async-channel",
@@ -1692,13 +1692,15 @@ dependencies = [
1692
1692
  "jsonwebtoken",
1693
1693
  "magnus",
1694
1694
  "md5",
1695
- "moka",
1695
+ "memchr",
1696
1696
  "nix",
1697
1697
  "notify",
1698
1698
  "num_cpus",
1699
1699
  "parking_lot",
1700
1700
  "percent-encoding",
1701
+ "phf",
1701
1702
  "pin-project",
1703
+ "quick_cache",
1702
1704
  "rand 0.9.1",
1703
1705
  "rcgen",
1704
1706
  "redis",
@@ -1879,7 +1881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1879
1881
  checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
1880
1882
  dependencies = [
1881
1883
  "cfg-if",
1882
- "windows-targets 0.48.5",
1884
+ "windows-targets 0.52.6",
1883
1885
  ]
1884
1886
 
1885
1887
  [[package]]
@@ -1927,19 +1929,6 @@ version = "0.4.27"
1927
1929
  source = "registry+https://github.com/rust-lang/crates.io-index"
1928
1930
  checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
1929
1931
 
1930
- [[package]]
1931
- name = "loom"
1932
- version = "0.7.2"
1933
- source = "registry+https://github.com/rust-lang/crates.io-index"
1934
- checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca"
1935
- dependencies = [
1936
- "cfg-if",
1937
- "generator",
1938
- "scoped-tls",
1939
- "tracing",
1940
- "tracing-subscriber",
1941
- ]
1942
-
1943
1932
  [[package]]
1944
1933
  name = "magnus"
1945
1934
  version = "0.7.1"
@@ -2043,25 +2032,6 @@ dependencies = [
2043
2032
  "windows-sys 0.52.0",
2044
2033
  ]
2045
2034
 
2046
- [[package]]
2047
- name = "moka"
2048
- version = "0.12.10"
2049
- source = "registry+https://github.com/rust-lang/crates.io-index"
2050
- checksum = "a9321642ca94a4282428e6ea4af8cc2ca4eac48ac7a6a4ea8f33f76d0ce70926"
2051
- dependencies = [
2052
- "crossbeam-channel",
2053
- "crossbeam-epoch",
2054
- "crossbeam-utils",
2055
- "loom",
2056
- "parking_lot",
2057
- "portable-atomic",
2058
- "rustc_version",
2059
- "smallvec",
2060
- "tagptr",
2061
- "thiserror 1.0.69",
2062
- "uuid",
2063
- ]
2064
-
2065
2035
  [[package]]
2066
2036
  name = "multer"
2067
2037
  version = "2.1.0"
@@ -2298,6 +2268,48 @@ version = "2.3.1"
2298
2268
  source = "registry+https://github.com/rust-lang/crates.io-index"
2299
2269
  checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
2300
2270
 
2271
+ [[package]]
2272
+ name = "phf"
2273
+ version = "0.11.3"
2274
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2275
+ checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
2276
+ dependencies = [
2277
+ "phf_macros",
2278
+ "phf_shared",
2279
+ ]
2280
+
2281
+ [[package]]
2282
+ name = "phf_generator"
2283
+ version = "0.11.3"
2284
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2285
+ checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
2286
+ dependencies = [
2287
+ "phf_shared",
2288
+ "rand 0.8.5",
2289
+ ]
2290
+
2291
+ [[package]]
2292
+ name = "phf_macros"
2293
+ version = "0.11.3"
2294
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2295
+ checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
2296
+ dependencies = [
2297
+ "phf_generator",
2298
+ "phf_shared",
2299
+ "proc-macro2",
2300
+ "quote",
2301
+ "syn 2.0.100",
2302
+ ]
2303
+
2304
+ [[package]]
2305
+ name = "phf_shared"
2306
+ version = "0.11.3"
2307
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2308
+ checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
2309
+ dependencies = [
2310
+ "siphasher",
2311
+ ]
2312
+
2301
2313
  [[package]]
2302
2314
  name = "pin-project"
2303
2315
  version = "1.1.10"
@@ -2336,12 +2348,6 @@ version = "0.3.32"
2336
2348
  source = "registry+https://github.com/rust-lang/crates.io-index"
2337
2349
  checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
2338
2350
 
2339
- [[package]]
2340
- name = "portable-atomic"
2341
- version = "1.11.0"
2342
- source = "registry+https://github.com/rust-lang/crates.io-index"
2343
- checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
2344
-
2345
2351
  [[package]]
2346
2352
  name = "powerfmt"
2347
2353
  version = "0.2.0"
@@ -2354,7 +2360,7 @@ version = "0.2.21"
2354
2360
  source = "registry+https://github.com/rust-lang/crates.io-index"
2355
2361
  checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
2356
2362
  dependencies = [
2357
- "zerocopy",
2363
+ "zerocopy 0.8.24",
2358
2364
  ]
2359
2365
 
2360
2366
  [[package]]
@@ -2400,6 +2406,18 @@ dependencies = [
2400
2406
  "unicode-ident",
2401
2407
  ]
2402
2408
 
2409
+ [[package]]
2410
+ name = "quick_cache"
2411
+ version = "0.6.13"
2412
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2413
+ checksum = "287e56aac5a2b4fb25a6fb050961d157635924c8696305a5c937a76f29841a0f"
2414
+ dependencies = [
2415
+ "ahash",
2416
+ "equivalent",
2417
+ "hashbrown",
2418
+ "parking_lot",
2419
+ ]
2420
+
2403
2421
  [[package]]
2404
2422
  name = "quinn"
2405
2423
  version = "0.11.7"
@@ -2772,15 +2790,6 @@ version = "2.1.1"
2772
2790
  source = "registry+https://github.com/rust-lang/crates.io-index"
2773
2791
  checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
2774
2792
 
2775
- [[package]]
2776
- name = "rustc_version"
2777
- version = "0.4.1"
2778
- source = "registry+https://github.com/rust-lang/crates.io-index"
2779
- checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
2780
- dependencies = [
2781
- "semver",
2782
- ]
2783
-
2784
2793
  [[package]]
2785
2794
  name = "rusticata-macros"
2786
2795
  version = "4.1.0"
@@ -2948,12 +2957,6 @@ dependencies = [
2948
2957
  "libc",
2949
2958
  ]
2950
2959
 
2951
- [[package]]
2952
- name = "semver"
2953
- version = "1.0.26"
2954
- source = "registry+https://github.com/rust-lang/crates.io-index"
2955
- checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
2956
-
2957
2960
  [[package]]
2958
2961
  name = "seq-macro"
2959
2962
  version = "0.3.6"
@@ -3119,6 +3122,12 @@ dependencies = [
3119
3122
  "windows-sys 0.48.0",
3120
3123
  ]
3121
3124
 
3125
+ [[package]]
3126
+ name = "siphasher"
3127
+ version = "1.0.1"
3128
+ source = "registry+https://github.com/rust-lang/crates.io-index"
3129
+ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
3130
+
3122
3131
  [[package]]
3123
3132
  name = "slab"
3124
3133
  version = "0.4.9"
@@ -3251,15 +3260,9 @@ dependencies = [
3251
3260
  "memchr",
3252
3261
  "ntapi",
3253
3262
  "rayon",
3254
- "windows 0.57.0",
3263
+ "windows",
3255
3264
  ]
3256
3265
 
3257
- [[package]]
3258
- name = "tagptr"
3259
- version = "0.2.0"
3260
- source = "registry+https://github.com/rust-lang/crates.io-index"
3261
- checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
3262
-
3263
3266
  [[package]]
3264
3267
  name = "tap"
3265
3268
  version = "1.0.1"
@@ -3689,15 +3692,6 @@ version = "0.2.2"
3689
3692
  source = "registry+https://github.com/rust-lang/crates.io-index"
3690
3693
  checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
3691
3694
 
3692
- [[package]]
3693
- name = "uuid"
3694
- version = "1.16.0"
3695
- source = "registry+https://github.com/rust-lang/crates.io-index"
3696
- checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9"
3697
- dependencies = [
3698
- "getrandom 0.3.2",
3699
- ]
3700
-
3701
3695
  [[package]]
3702
3696
  name = "valuable"
3703
3697
  version = "0.1.1"
@@ -3945,16 +3939,6 @@ dependencies = [
3945
3939
  "windows-targets 0.52.6",
3946
3940
  ]
3947
3941
 
3948
- [[package]]
3949
- name = "windows"
3950
- version = "0.58.0"
3951
- source = "registry+https://github.com/rust-lang/crates.io-index"
3952
- checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
3953
- dependencies = [
3954
- "windows-core 0.58.0",
3955
- "windows-targets 0.52.6",
3956
- ]
3957
-
3958
3942
  [[package]]
3959
3943
  name = "windows-core"
3960
3944
  version = "0.57.0"
@@ -3967,19 +3951,6 @@ dependencies = [
3967
3951
  "windows-targets 0.52.6",
3968
3952
  ]
3969
3953
 
3970
- [[package]]
3971
- name = "windows-core"
3972
- version = "0.58.0"
3973
- source = "registry+https://github.com/rust-lang/crates.io-index"
3974
- checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
3975
- dependencies = [
3976
- "windows-implement 0.58.0",
3977
- "windows-interface 0.58.0",
3978
- "windows-result 0.2.0",
3979
- "windows-strings 0.1.0",
3980
- "windows-targets 0.52.6",
3981
- ]
3982
-
3983
3954
  [[package]]
3984
3955
  name = "windows-core"
3985
3956
  version = "0.61.0"
@@ -4004,17 +3975,6 @@ dependencies = [
4004
3975
  "syn 2.0.100",
4005
3976
  ]
4006
3977
 
4007
- [[package]]
4008
- name = "windows-implement"
4009
- version = "0.58.0"
4010
- source = "registry+https://github.com/rust-lang/crates.io-index"
4011
- checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
4012
- dependencies = [
4013
- "proc-macro2",
4014
- "quote",
4015
- "syn 2.0.100",
4016
- ]
4017
-
4018
3978
  [[package]]
4019
3979
  name = "windows-implement"
4020
3980
  version = "0.60.0"
@@ -4037,17 +3997,6 @@ dependencies = [
4037
3997
  "syn 2.0.100",
4038
3998
  ]
4039
3999
 
4040
- [[package]]
4041
- name = "windows-interface"
4042
- version = "0.58.0"
4043
- source = "registry+https://github.com/rust-lang/crates.io-index"
4044
- checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
4045
- dependencies = [
4046
- "proc-macro2",
4047
- "quote",
4048
- "syn 2.0.100",
4049
- ]
4050
-
4051
4000
  [[package]]
4052
4001
  name = "windows-interface"
4053
4002
  version = "0.59.1"
@@ -4085,15 +4034,6 @@ dependencies = [
4085
4034
  "windows-targets 0.52.6",
4086
4035
  ]
4087
4036
 
4088
- [[package]]
4089
- name = "windows-result"
4090
- version = "0.2.0"
4091
- source = "registry+https://github.com/rust-lang/crates.io-index"
4092
- checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
4093
- dependencies = [
4094
- "windows-targets 0.52.6",
4095
- ]
4096
-
4097
4037
  [[package]]
4098
4038
  name = "windows-result"
4099
4039
  version = "0.3.2"
@@ -4103,16 +4043,6 @@ dependencies = [
4103
4043
  "windows-link",
4104
4044
  ]
4105
4045
 
4106
- [[package]]
4107
- name = "windows-strings"
4108
- version = "0.1.0"
4109
- source = "registry+https://github.com/rust-lang/crates.io-index"
4110
- checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
4111
- dependencies = [
4112
- "windows-result 0.2.0",
4113
- "windows-targets 0.52.6",
4114
- ]
4115
-
4116
4046
  [[package]]
4117
4047
  name = "windows-strings"
4118
4048
  version = "0.3.1"
@@ -4415,13 +4345,33 @@ dependencies = [
4415
4345
  "synstructure",
4416
4346
  ]
4417
4347
 
4348
+ [[package]]
4349
+ name = "zerocopy"
4350
+ version = "0.7.35"
4351
+ source = "registry+https://github.com/rust-lang/crates.io-index"
4352
+ checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
4353
+ dependencies = [
4354
+ "zerocopy-derive 0.7.35",
4355
+ ]
4356
+
4418
4357
  [[package]]
4419
4358
  name = "zerocopy"
4420
4359
  version = "0.8.24"
4421
4360
  source = "registry+https://github.com/rust-lang/crates.io-index"
4422
4361
  checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
4423
4362
  dependencies = [
4424
- "zerocopy-derive",
4363
+ "zerocopy-derive 0.8.24",
4364
+ ]
4365
+
4366
+ [[package]]
4367
+ name = "zerocopy-derive"
4368
+ version = "0.7.35"
4369
+ source = "registry+https://github.com/rust-lang/crates.io-index"
4370
+ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
4371
+ dependencies = [
4372
+ "proc-macro2",
4373
+ "quote",
4374
+ "syn 2.0.100",
4425
4375
  ]
4426
4376
 
4427
4377
  [[package]]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-scheduler"
3
- version = "0.2.13"
3
+ version = "0.2.15"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -111,7 +111,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
111
111
 
112
112
  [[package]]
113
113
  name = "atty"
114
- version = "0.2.14"
114
+ version = "0.2.15"
115
115
  source = "registry+https://github.com/rust-lang/crates.io-index"
116
116
  checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
117
117
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-server"
3
- version = "0.2.13"
3
+ version = "0.2.15"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -43,7 +43,6 @@ itsi_tracing = { path = "../itsi_tracing" }
43
43
  itsi_acme = { path = "../itsi_acme" }
44
44
  jsonwebtoken = "9.3.1"
45
45
  magnus = { version = "0.7.1", features = ["bytes", "rb-sys"] }
46
- moka = { version = "0.12.10", features = ["sync"] }
47
46
  notify = { version = "8.0.0" }
48
47
  nix = { version = "0.29.0", features = [
49
48
  "socket",
@@ -55,6 +54,7 @@ nix = { version = "0.29.0", features = [
55
54
  num_cpus = "1.16.0"
56
55
  parking_lot = "0.12.3"
57
56
  pin-project = "1.1.9"
57
+ phf = { version = "0.11.3", features = ["macros"] }
58
58
  rand = "0.9.0"
59
59
  rcgen = { version = "0.13.2", features = ["x509-parser", "pem"] }
60
60
  regex = "1.11.1"
@@ -88,3 +88,5 @@ percent-encoding = "2.3.1"
88
88
  sha-crypt = "0.5.0"
89
89
  argon2 = "0.5.3"
90
90
  core_affinity = "0.8.3"
91
+ memchr = "2.7.4"
92
+ quick_cache = "0.6.13"
@@ -1,4 +1,4 @@
1
- use bytes::{Bytes, BytesMut};
1
+ use bytes::{Buf, Bytes, BytesMut};
2
2
  use derive_more::Debug;
3
3
  use futures::stream::{unfold, StreamExt};
4
4
  use http::{
@@ -12,6 +12,7 @@ use hyper_util::rt::TokioIo;
12
12
  use itsi_error::Result;
13
13
  use itsi_tracing::error;
14
14
  use magnus::error::Result as MagnusResult;
15
+ use memchr::{memchr, memchr_iter};
15
16
  use parking_lot::RwLock;
16
17
  use std::{
17
18
  collections::HashMap,
@@ -345,13 +346,54 @@ impl ItsiHttpResponse {
345
346
  let header_name: HeaderName = HeaderName::from_bytes(&name).map_err(|e| {
346
347
  itsi_error::ItsiError::InvalidInput(format!("Invalid header name {:?}: {:?}", name, e))
347
348
  })?;
348
- let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
349
349
  if let Some(ref mut resp) = *self.data.response.write() {
350
- resp.headers_mut().append(header_name, header_value);
350
+ let headers_mut = resp.headers_mut();
351
+ self.insert_header(headers_mut, &header_name, value);
351
352
  }
352
353
  Ok(())
353
354
  }
354
355
 
356
+ pub fn insert_header(
357
+ &self,
358
+ headers_mut: &mut HeaderMap,
359
+ header_name: &HeaderName,
360
+ value: Bytes,
361
+ ) {
362
+ static MAX_SPLIT_HEADERS: usize = 100;
363
+
364
+ let mut start = 0usize;
365
+ let mut emitted = 0usize;
366
+
367
+ for idx in memchr_iter(b'\n', &value).chain(std::iter::once(value.len())) {
368
+ if idx == start {
369
+ start += 1;
370
+ continue;
371
+ }
372
+
373
+ let mut part = value.slice(start..idx);
374
+ if part.ends_with(b"\r") {
375
+ part.truncate(part.len() - 1);
376
+ }
377
+ if let Some(&(b' ' | b'\t')) = part.first() {
378
+ part.advance(1);
379
+ }
380
+ if memchr(0, &part).is_some() || part.iter().any(|&b| b < 0x20) {
381
+ warn!("stripped control char from header {:?}", header_name);
382
+ start = idx + 1;
383
+ continue;
384
+ }
385
+
386
+ emitted += 1;
387
+ if emitted > MAX_SPLIT_HEADERS {
388
+ break;
389
+ }
390
+
391
+ let hv = unsafe { HeaderValue::from_maybe_shared_unchecked(part) };
392
+ headers_mut.append(header_name, hv);
393
+ start = idx + 1;
394
+ }
395
+ }
396
+
355
397
  pub fn add_headers(&self, headers: HashMap<Bytes, Vec<Bytes>>) -> MagnusResult<()> {
356
398
  if let Some(ref mut resp) = *self.data.response.write() {
357
399
  let headers_mut = resp.headers_mut();
@@ -363,8 +405,7 @@ impl ItsiHttpResponse {
363
405
  ))
364
406
  })?;
365
407
  for value in values {
366
- let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
367
- headers_mut.append(&header_name, header_value);
408
+ self.insert_header(headers_mut, &header_name, value);
368
409
  }
369
410
  }
370
411
  }
@@ -16,10 +16,15 @@ use http::{
16
16
  };
17
17
  use itsi_error::ItsiError;
18
18
  use magnus::error::Result;
19
- use moka::sync::Cache;
19
+ use quick_cache::sync::Cache;
20
20
  use regex::Regex;
21
21
  use serde::Deserialize;
22
- use std::{collections::HashMap, path::PathBuf, sync::OnceLock, time::Duration};
22
+ use std::{
23
+ collections::HashMap,
24
+ path::PathBuf,
25
+ sync::{Arc, OnceLock},
26
+ time::Duration,
27
+ };
23
28
  use tracing::debug;
24
29
 
25
30
  #[derive(Debug, Deserialize)]
@@ -76,10 +81,7 @@ impl MiddlewareLayer for StaticAssets {
76
81
  recheck_interval: Duration::from_secs(self.file_check_interval),
77
82
  serve_hidden_files: self.serve_hidden_files,
78
83
  allowed_extensions: self.allowed_extensions.clone(),
79
- miss_cache: Cache::builder()
80
- .max_capacity(self.max_files_in_memory)
81
- .time_to_live(Duration::from_secs(self.file_check_interval))
82
- .build(),
84
+ miss_cache: Arc::new(Cache::new(self.max_files_in_memory as usize)),
83
85
  })?)
84
86
  .map_err(ItsiError::new)?;
85
87
  Ok(())