Commit Graph

17 Commits

Author SHA1 Message Date
Guillaume Gomez
e330d30964 docs(lib): fix rustdoc warnings 2017-11-10 10:22:33 -08:00
Sean McArthur
19caf54edd chore(lib): fix nightly unused warning about AsciiExt 2017-11-06 17:58:12 -08:00
nabijaczleweli
d48ab9601b docs(headers): fix >-quote formatting
'>'s as non-first characters are just '>'s (rustfmt probably broke the
line)
2017-10-15 15:00:49 +02:00
Sean McArthur
6f02d43ae0 refactor(header): change Header::fmt_header to take a header::Formatter
The `header::Formatter` ensures that a formatted header is written to a
line, and allows for headers that require multiple lines. The only
header to specifically require this is `Set-Cookie`.

BREAKING CHANGE: The `fmt_header` method has changed to take a different
  formatter. In most cases, if your header also implements
  `fmt::Display`, you can just call `f.fmt_line(self)`.
2017-04-24 10:56:05 -07:00
Sean McArthur
e9e7381ece feat(header): implement fmt::Display for several headers
Specifically, `CacheControl`, `Expect`, `Origin`, `Pragma`, `Prefer`,
`PreferenceApplied`, `ReferrerPolicy`, `StrictTransportSecurity`.
2017-01-31 23:58:07 -08:00
Sean McArthur
50ccdaa7e7 feat(header): introduce header::Raw (#869)
The Raw type repesents the raw bytes of a header-value.

Having a special type allows a couple of benefits:

- The exact representation has become private, allowing "uglier"
internals. Specifically, since the common case is for a header to only
have 1 line of bytes, an enum is used to skip allocating a Vec for only
1 line. Additionally, a Cow<'static, [u8]> is used, so static bytes
don't require a copy. Finally, since we can use static bytes, when
parsing, we can compare the incoming bytes against a couple of the most
common header-values, and possibly remove another copy.

- As its own type, the `Headers.set_raw` method can be generic over
`Into<Raw>`, which allows for more ergnomic method calls.

BREAKING CHANGE: `Header::parse_header` now receives `&Raw`, instead of
  a `&[Vec<u8>]`. `Raw` provides several methods to ease using it, but
  may require some changes to existing code.
2016-07-23 12:54:16 -07:00
Sean McArthur
d80d61cd78 perf(headers): check for header literals before allocating name 2016-06-01 15:09:54 -07:00
Sean McArthur
d35992d019 feat(lib): switch to non-blocking (asynchronous) IO
BREAKING CHANGE: This breaks a lot of the Client and Server APIs.
  Check the documentation for how Handlers can be used for asynchronous
  events.
2016-05-16 09:51:18 -07:00
Chandler Latour
c940e84a78 docs(headers): add header examples 2015-06-14 21:32:33 -06:00
Pyfisch
195a89fa91 refactor(headers): errors for parse_header
Header::parse_header() returns now a hyper Result instead of an option
this will enable more precise Error messages in the future, currently
most failures are reported as ::Error::Header.

BREAKING CHANGE: parse_header returns Result instead of Option, related
code did also change
2015-06-10 22:22:56 +02:00
Sean McArthur
7e3858c962 perf(all): replace &str.to_string() with .to_owned() 2015-05-12 23:01:58 -07:00
Pyfisch
66d54d03e7 refactor(headers): Improve docs, fix nits, make formatting faster
src/header/parsing.rs now uses unsafe get_unchecked() again, I don't
know why it was removed.
2015-05-03 13:56:32 +02:00
Pyfisch
a6974c99d3 refactor(headers): Fail to parse single value header values
A single value header value can't be "", so `from_one_raw_str()` now
returns `None` on empty values. This makes custom checks in headers
obsolete.

BREAKING CHANGE: `from_one_raw_str()` returns `None` on empty values.
2015-05-02 16:40:53 +02:00
Pyfisch
6b59bd28b7 refactor(hyper): Fix a few nits 2015-05-01 11:58:15 +02:00
Florian Hartwig
3e456f00f9 fix(rustup): rustc 1.0.0-nightly (123a754cb 2015-03-24)
* fix `extern crate` declaration for rustc-serialize
* enable `into_cow` feature
* replace as_slice() calls by as_ref and enable `convert` feature
* use `core` feature in doc tests
2015-03-25 20:55:42 +01:00
Renato Zannon
039e984f68 fix(rustup): Remove uses of the obsolete &a[] syntax 2015-02-21 15:05:50 -08:00
Pyfisch
767c95d2b9 feat(headers): Add Pragma header field
Add the HTTP/1.0 `Pragma` header field used to prevent older Caches, that
do not understand the `Cache-Control` header field from caching the ressource.

Closes #237
2015-01-24 15:09:59 +01:00