Debian Codegraph @

third_party/rust/httpdate/README.md

raw
1 # Date and time utils for HTTP.
2
3 [![Build Status](https://travis-ci.org/pyfisch/httpdate.svg?branch=master)](https://travis-ci.org/pyfisch/httpdate)
4 [![Crates.io](https://img.shields.io/crates/v/httpdate.svg)](https://crates.io/crates/httpdate)
5 [![Documentation](https://docs.rs/httpdate/badge.svg)](https://docs.rs/httpdate)
6
7 Multiple HTTP header fields store timestamps.
8 For example a response created on May 15, 2015 may contain the header
9 `Date: Fri, 15 May 2015 15:34:21 GMT`. Since the timestamp does not
10 contain any timezone or leap second information it is equvivalent to
11 writing 1431696861 Unix time. Rust’s `SystemTime` is used to store
12 these timestamps.
13
14 This crate provides two public functions:
15
16 * `parse_http_date` to parse a HTTP datetime string to a system time
17 * `fmt_http_date` to format a system time to a IMF-fixdate
18
19 In addition it exposes the `HttpDate` type that can be used to parse
20 and format timestamps. Convert a sytem time to `HttpDate` and vice versa.
21 The `HttpType` (8 bytes) is smaller than `SystemTime` (16 bytes) and
22 using the display impl avoids a temporary allocation.
23
24 Read the [blog post](https://pyfisch.org/blog/http-datetime-handling/) to learn
25 more.
26
27 Fuzz it by installing *cargo-fuzz* and running `cargo fuzz run fuzz_target_1`.