wt: patch web-transport-proto header interop for Cloudflare relay
This commit is contained in:
parent
aa4bddcba0
commit
523c601dc3
17 changed files with 2567 additions and 2 deletions
18
third_party/web-transport-proto/src/error.rs
vendored
Normal file
18
third_party/web-transport-proto/src/error.rs
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// WebTransport shares with HTTP/3, so we can't start at 0 or use the full VarInt.
|
||||
const ERROR_FIRST: u64 = 0x52e4a40fa8db;
|
||||
const ERROR_LAST: u64 = 0x52e5ac983162;
|
||||
|
||||
pub const fn error_from_http3(code: u64) -> Option<u32> {
|
||||
if code < ERROR_FIRST || code > ERROR_LAST {
|
||||
return None;
|
||||
}
|
||||
|
||||
let code = code - ERROR_FIRST;
|
||||
let code = code - code / 0x1f;
|
||||
|
||||
Some(code as u32)
|
||||
}
|
||||
|
||||
pub const fn error_to_http3(code: u32) -> u64 {
|
||||
ERROR_FIRST + code as u64 + code as u64 / 0x1e
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue