Merge remote-tracking branch 'origin/upstream' am: ea8079c257 am: 279bb16e3d

Original change: undetermined

Change-Id: I643624349f4dfec306f71b30b966e185fa8b7598
Signed-off-by: Automerger Merge Worker <[email protected]>
tree: 7fb6a4c59d42a9167504337be36845ca17e0d21b
  1. benches/
  2. src/
  3. Android.bp
  4. Cargo.toml
  5. Cargo.toml.orig
  6. cargo_embargo.json
  7. LICENSE-APACHE
  8. LICENSE-MIT
  9. METADATA
  10. MODULE_LICENSE_APACHE2
  11. OWNERS
  12. 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.