Files
hyper/src/header/common/server.rs
hag c8d5bf5cc8 refactor(header): make some headers more allocator friendly
Change the internal implementation of some simple headers to make them
more allocator friendly. Also add a constructor method to allow changing
the implementation in the future again.

The headers are:

- Location
- Referrer
- Server
- UserAgent

This change was suggested in [#1104].

BREAKING CHANGES:
- Old code that creates the header structs directly will stop working.
- It's not possible to implement DerefMut for a Cow<'static,str>. Code
that needs to modify header after creation will stop working.
2017-04-10 10:48:16 +02:00

37 lines
1.2 KiB
Rust

header! {
/// `Server` header, defined in [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.4.2)
///
/// The `Server` header field contains information about the software
/// used by the origin server to handle the request, which is often used
/// by clients to help identify the scope of reported interoperability
/// problems, to work around or tailor requests to avoid particular
/// server limitations, and for analytics regarding server or operating
/// system use. An origin server MAY generate a Server field in its
/// responses.
///
/// # ABNF
/// ```plain
/// Server = product *( RWS ( product / comment ) )
/// ```
///
/// # Example values
/// * `CERN/3.0 libwww/2.17`
///
/// # Example
/// ```
/// use hyper::header::{Headers, Server};
///
/// let mut headers = Headers::new();
/// headers.set(Server::new("hyper/0.5.2"));
/// ```
// TODO: Maybe parse as defined in the spec?
(Server, "Server") => Cow[str]
test_server {
// Testcase from RFC
test_header!(test1, vec![b"CERN/3.0 libwww/2.17"]);
}
}
bench_header!(bench, Server, { vec![b"Some String".to_vec()] });