commit | 8f0f3f4a8628e5e4b50c14406155dc31d79b97c2 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Wed Aug 28 15:34:23 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed Aug 28 15:34:23 2024 +0000 |
tree | deb9c11af42f9d8c873eb2a36bc1a4d5660d502e | |
parent | 8fd6b2be69956763c08767ea97d2c47d100991de [diff] | |
parent | 1a2b3261a6610216b4a7368234e50953a8b3c7b6 [diff] |
Migrate 25 crates to monorepo. am: 5545d960c1 am: 1a2b3261a6 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/httpdate/+/3243828 Change-Id: Iab1c75d5adad32ca829d5a48dac0858366cf027b Signed-off-by: Automerger Merge Worker <[email protected]>
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
.