diff options
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-cache/src/meta.rs | 15 | ||||
-rw-r--r-- | pingora-header-serde/src/dict.rs | 17 |
3 files changed, 31 insertions, 3 deletions
@@ -1 +1 @@ -735c778b671dcfcbe0b561cc0bbbf0f000e457f6
\ No newline at end of file +aa7c01c0f1c7a33d4ec55cf3531997e4cb2542ab
\ No newline at end of file diff --git a/pingora-cache/src/meta.rs b/pingora-cache/src/meta.rs index 206b320..8ed034e 100644 --- a/pingora-cache/src/meta.rs +++ b/pingora-cache/src/meta.rs @@ -595,8 +595,19 @@ fn load_file(path: &String) -> Option<Vec<u8>> { } static HEADER_SERDE: Lazy<HeaderSerde> = Lazy::new(|| { - let dict = COMPRESSION_DICT_PATH.get().and_then(load_file); - HeaderSerde::new(dict) + let dict_path_opt = COMPRESSION_DICT_PATH.get(); + + if dict_path_opt.is_none() { + warn!("COMPRESSION_DICT_PATH is not set"); + } + + let result = dict_path_opt.and_then(load_file); + + if result.is_none() { + warn!("HeaderSerde not loaded from file"); + } + + HeaderSerde::new(result) }); pub(crate) fn header_serialize(header: &ResponseHeader) -> Result<Vec<u8>> { diff --git a/pingora-header-serde/src/dict.rs b/pingora-header-serde/src/dict.rs index bc50ada..71a85b6 100644 --- a/pingora-header-serde/src/dict.rs +++ b/pingora-header-serde/src/dict.rs @@ -74,6 +74,23 @@ mod test { } #[test] + fn test_deserialize_with_dict() { + let dict = gen_test_dict(); + let serde = crate::HeaderSerde::new(Some(dict)); + let serde_no_dict = crate::HeaderSerde::new(None); + let header = gen_test_header(); + + let compressed = serde.serialize(&header).unwrap(); + let compressed_no_dict = serde_no_dict.serialize(&header).unwrap(); + + let from_dict_header = serde.deserialize(&compressed).unwrap(); + let from_no_dict_header = serde_no_dict.deserialize(&compressed_no_dict).unwrap(); + + assert_eq!(from_dict_header.status, from_no_dict_header.status); + assert_eq!(from_dict_header.headers, from_no_dict_header.headers); + } + + #[test] fn test_ser_de_with_dict() { let dict = gen_test_dict(); let serde = crate::HeaderSerde::new(Some(dict)); |