Skip to content

Commit 3608382

Browse files
authored
Merge pull request #862 from puhrez/last-event-id-0.9.x
feat(headers): add last-event-id header
2 parents 8696b8b + 2277987 commit 3608382

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/header/common/last-event-id.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
header! {
2+
/// `Last-Event-ID` header, defined in
3+
/// [RFC3864](https://html.spec.whatwg.org/multipage/references.html#refsRFC3864)
4+
///
5+
/// The `Last-Event-ID` header contains information about
6+
/// the last event in an http interaction so that it's easier to
7+
/// track of event state. This is helpful when working
8+
/// with [Server-Sent-Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/). If the connection were to be dropped, for example, it'd
9+
/// be useful to let the server know what the last event you
10+
/// recieved was.
11+
///
12+
/// The spec is a String with the id of the last event, it can be
13+
/// an empty string which acts a sort of "reset".
14+
///
15+
/// # Example
16+
/// ```
17+
/// use hyper::header::{Headers, LastEventID};
18+
///
19+
/// let mut headers = Headers::new();
20+
/// headers.set(LastEventID("1".to_owned()));
21+
/// ```
22+
(LastEventID, "Last-Event-ID") => [String]
23+
24+
test_last_event_id {
25+
// Initial state
26+
test_header!(test1, vec![b""]);
27+
// Own testcase
28+
test_header!(test2, vec![b"1"], Some(LastEventID("1".to_owned())));
29+
}
30+
}

0 commit comments

Comments
 (0)