Snap for 12289667 from 8f0f3f4a8628e5e4b50c14406155dc31d79b97c2 to 24Q4-release

Change-Id: I8c6fafe1f299ecedddadecf4cfd38ad5179d7377
tree: deb9c11af42f9d8c873eb2a36bc1a4d5660d502e
  1. benches/
  2. src/
  3. Android.bp
  4. Cargo.toml
  5. Cargo.toml.orig
  6. LICENSE-APACHE
  7. LICENSE-MIT
  8. METADATA
  9. MODULE_LICENSE_APACHE2
  10. OWNERS
  11. README.md
README.md

Date and time utils for HTTP.

Build Status Crates.io Documentation

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 time
  • fmt_http_date to format a system time to a IMF-fixdate

In 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.