commit | 67ab2eed53cf5cb744a01786cbe44ed6723d72a2 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Aug 08 01:12:41 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Aug 08 01:12:41 2024 +0000 |
tree | c733d76f2f07df7b77dafda07e5706f6e8885f79 | |
parent | b5fcd0499a75a0cce309ed93d3c601c0c7ba024e [diff] | |
parent | 8fd6b2be69956763c08767ea97d2c47d100991de [diff] |
Snap for 12199973 from 8fd6b2be69956763c08767ea97d2c47d100991de to 24Q4-release Change-Id: I26080ea0b75f72067ab3d790800b0ba788a16706
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
.