| commit | 2b468f8ae9079325a5772ae1cb60459a2680cbbb | [log] [tgz] |
|---|---|---|
| author | Viktoriia Kovalova <[email protected]> | Tue May 28 12:04:20 2024 +0000 |
| committer | Viktoriia Kovalova <[email protected]> | Tue May 28 16:55:41 2024 +0000 |
| tree | 7fb6a4c59d42a9167504337be36845ca17e0d21b | |
| parent | 469950f5d1ed2fa9ae7140cfe38c408ceca602f9 [diff] |
Import 'httpdate' crate Request Document: go/android-rust-importing-crates For CL Reviewers: go/android3p#cl-review For Build Team: go/ab-third-party-imports Bug: http://b/339187656 Test: m libhttpdate && atest --host httpdate_test_src_lib Change-Id: Iab7862e17e15b9631945b3ee9b334ca1d11fc434
Multiple HTTP header fields store timestamps. For example a response created on May 15, 2015 may contain the header Date: Fri, 15 May 2015 15:34:21 GMT. Since the timestamp does not contain any timezone or leap second information it is equvivalent to writing 1431696861 Unix time. Rust’s SystemTime is used to store these timestamps.
This crate provides two public functions:
parse_http_date to parse a HTTP datetime string to a system timefmt_http_date to format a system time to a IMF-fixdateIn addition it exposes the HttpDate type that can be used to parse and format timestamps. Convert a sytem time to HttpDate and vice versa. The HttpDate (8 bytes) is smaller than SystemTime (16 bytes) and using the display impl avoids a temporary allocation.
Read the blog post to learn more.
Fuzz it by installing cargo-fuzz and running cargo fuzz run fuzz_target_1.