fix(http): separate transport and protocol limits

This commit is contained in:
2026-10-02 02:50:56 +09:00
parent 65c51006ad
commit df006ee706
12 changed files with 643 additions and 336 deletions
+6 -14
View File
@@ -10,11 +10,11 @@ use wip_http::wip_protocol::{
};
use wip_http::{
ClientResponseError, CodecError, DecodedResponse, Endpoint, InvalidResponseKind, Limits,
ResourceLimitKind, decode_call_operation_metadata, decode_call_operation_request,
decode_call_operation_response, decode_fetch_interface_request,
decode_fetch_interface_response, decode_observe_request, decode_observe_response,
encode_call_operation_request, encode_call_operation_response, encode_fetch_interface_request,
encode_fetch_interface_response, encode_observe_request, encode_observe_response,
decode_call_operation_metadata, decode_call_operation_request, decode_call_operation_response,
decode_fetch_interface_request, decode_fetch_interface_response, decode_observe_request,
decode_observe_response, encode_call_operation_request, encode_call_operation_response,
encode_fetch_interface_request, encode_fetch_interface_response, encode_observe_request,
encode_observe_response,
};
fn limits() -> Limits {
@@ -404,23 +404,15 @@ fn malformed_unknown_null_and_noncanonical_base64_are_rejected() {
}
#[test]
fn caller_limits_bound_bytes_and_nesting() {
fn caller_limits_remain_local_codec_failures() {
let tiny = Limits::new(8, 8, 2, 1).unwrap();
let too_large = decode_observe_request(br#"{"path":"/long","depth":0}"#, tiny).unwrap_err();
assert!(matches!(&too_large, CodecError::BodyTooLarge { .. }));
assert_eq!(
too_large.resource_limit_kind(),
Some(ResourceLimitKind::RepresentationBytes)
);
let nested = br#"{"path":[[["/"]]],"depth":0}"#;
let nesting_limited = Limits::new(1024, 1024, 2, 1).unwrap();
let too_deep = decode_observe_request(nested, nesting_limited).unwrap_err();
assert!(matches!(&too_deep, CodecError::NestingTooDeep { .. }));
assert_eq!(
too_deep.resource_limit_kind(),
Some(ResourceLimitKind::Logical)
);
let outbound_limited = Limits::new(1_000_000, 1_000_000, 1, 10).unwrap();
assert!(