Commit Graph

283 Commits

Author SHA1 Message Date
Sean McArthur
61364d245b perf(header): improve on MemSlice usage in headers 2017-01-26 23:49:44 -08:00
Guillaume Gomez
1b556389c0 perf(header): use MemSlice when parsing headers 2017-01-26 10:07:34 -08:00
Andy Moran
529ad564c3 refactor(header): Change to base64 serialize
Replace rustc-serialize with base64 crate.

Closes #1028
2017-01-23 23:09:14 -08:00
Sean McArthur
8e790831c1 fix(header): security fix for header values that include newlines
Newlines in header values will now be replaced with spaces when being
written to strings or to sockets. This prevents headers that are built
from user data to smuggle unintended headers or requests/responses.

Thanks to @skylerberg for the responsible reporting of this issue, and
helping to keep us all safe!

BREAKING CHANGE: This technically will cause code that a calls
  `SetCookie.fmt_header` to panic, as it is no longer to properly write
  that method. Most people should not be doing this at all, and all
  other ways of printing headers should work just fine.

  The breaking change must occur in a patch version because of the
  security nature of the fix.
2017-01-23 12:55:56 -08:00
Julius de Bruijn
1037bc7732 feat(header): Add support for Retry-After header
This used to be an external crate, https://github.com/jwilm/retry-after
2017-01-19 15:29:05 -08:00
derekdreery
b64665635f docs(headers): Explain content_type assigned type
Explain why content_type mime params are not generic over slice.

Related to #991
2017-01-17 16:05:54 -08:00
Sean McArthur
cd9fd52207 refactor(header): Host header internals made private
This allows us to improve the performance. For now, a Cow is used
internally, so clients can set the host to a static value and no longer
need copies.

Later, we can change it to also possibly have a MemSlice.

BREAKING CHANGE: The fields of the `Host` header are no longer
  available. Use the getter methods instead.
2017-01-16 10:50:36 -08:00
Sean McArthur
0167f57d65 docs(cookie): fix examples for Cookie and SetCookie 2017-01-16 10:50:36 -08:00
Sean McArthur
637b170f52 refactor(header): change Cookie and SetCookie to use String
This removes the cookie crate, since it has an optional dependency on
openssl, which can cause massive breakage if toggled on. Instead, the
`Cookie` and `SetCookie` headers now just use a `String`. Anyone can
create any typed header, so it is easy to plug in different
implementations.

BREAKING CHANGE: The `Cookie` and `SetCookie` headers no longer use the
  cookie crate. New headers can be written for any header, or the ones
  provided in hyper can be accessed as strings.
2017-01-16 10:50:35 -08:00
Sean McArthur
2d2d5574a6 feat(lib): redesign API to use Futures and Tokio
There are many changes involved with this, but let's just talk about
user-facing changes.

- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.

BREAKING CHANGE: A big sweeping set of breaking changes.
2017-01-16 10:44:27 -08:00
Sean McArthur
bdc19d52bf feat(headers): add star, json, text, image constructors to Accept 2016-12-10 12:22:08 -08:00
Sean McArthur
02f01765ee fix(tests): update new Host header tests to use Raw 2016-11-16 12:57:09 -08:00
Markus Unterwaditzer
8541ac72d7 fix(headers): Allow IPv6 Addresses in Host header 2016-11-01 14:44:56 -07:00
Raghav
3593d7987a feat(headers): Add strict-origin and strict-origin-when-cross-origin referer policy
Support for strict-origin and strict-origin-when-cross-origin in referer
policy required for imporving network security. This commit will attempt
to add missing pieces of referrer policy.
2016-10-28 16:56:40 -04:00
Tshepang Lekhonkhobe
d5df3fd1b5 docs(headers): remove extraneous space 2016-10-13 14:25:52 -07:00
Garrett Squire
7b558ae87a feat(headers): support multiple values for Referrer-Policy header
Closes #882
2016-10-08 11:10:07 -07:00
Simon Smith
69894d1994 feat(headers): add Warning header
Implements Warning header from RFC7234
Closes #883
2016-09-05 14:35:48 -04:00
Joonas Koivunen
13c5bf66c3 feat(headers): add Content-Location header
Closes #870
2016-07-28 09:59:33 -07: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
Michael
e1542a609f feat(headers): add last-event-id header
Add a Last-Event-ID header to properly work with Server-Sent Events

Addresses # 723
2016-07-14 20:38:46 -07:00
Sean McArthur
40745c5671 refactor(lib): moved LanguageTag export to header
BREAKING CHANGE: LanguageTag used to be at the crate root, but it is now
  in the `hyper::header` module.
2016-07-14 09:59:47 -07:00
Michael
01843f8822 feat(headers): add origin header
Add an Origin header so users may properly send CORS requests

Closes #651
2016-07-13 14:50:52 -07:00
Aravind Gollakota
3a86b3a2b2 feat(headers): Add Referrer-Policy header 2016-07-01 22:17:11 -07:00
leonardo.yvens
d4a095d75c refactor(multiple): Clippy run 2016-06-12 15:17:15 -03:00
Sean McArthur
d80d61cd78 perf(headers): check for header literals before allocating name 2016-06-01 15:09:54 -07:00
Justin Mayhew
8f1c536007 docs(*): fix typos, Markdown inconsistencies, and stutter 2016-05-20 11:42:29 -03: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
Manish Goregaokar
b840963629 docs(*): Clippy fixes with markdown docs 2016-05-05 22:50:23 +05:30
Simon Sapin
8fa7a98968 refactor(hyper): Update to rust-url 1.0
BREAKING CHANGE: The re-exported Url type has breaking changes.
2016-04-21 16:14:08 -07:00
Sean McArthur
bc3878de36 Merge pull request #750 from calebmer/feat/prefer
feat(header): add prefer and preference applied headers
2016-03-31 18:56:58 -07:00
calebmer
6f6493010a feat(header): add prefer and preference applied headers
Closes #747
2016-03-31 15:46:34 -04:00
Sean McArthur
cbf83a4d5a Merge pull request #751 from hyperium/per-tag-docs
chore(docs): publish docs per version
2016-03-24 19:52:47 -07:00
Sean McArthur
905e0d2ff4 chore(docs): publish docs per version 2016-03-24 18:57:23 -07:00
Steven Allen
70c6914217 fix(headers): correctly handle repeated headers
HeaderX: a
    HeaderX: b

MUST be interpreted as

    HeaderX: a, b

See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Fixes #683
2016-03-24 14:19:15 -07:00
Danilo Bargen
eedd5b73ee docs(headers): Remove charset from json() docs
Leftover from ec568e9a55.
2016-03-15 12:33:32 +01:00
Garrett Squire
ec568e9a55 fix(headers): remove charset from ContentType::json() convenience method
since the JSON mime type does not accept a charset, this patch removes
it

closes https://github.com/hyperium/hyper/issues/737
2016-03-08 17:41:34 -08:00
Corey Farwell
4c7f6f0c1e style(all): Address suggestions made by rust-clippy 2015-12-23 08:59:45 -08:00
Mark Lee
402fb76bb2 feat(headers): add extended parameter parser to the public API
Move the extended parameter parser from the Content-Disposition header
implementation into the common header parsing module. This allows crates that
use Hyper to parse RFC 5987-compliant header parameter values.
Add tests based on the examples given in the RFC.
2015-12-15 09:56:09 -08:00
Mike Dilger
7623ecc264 feat(headers): Add Content-Disposition header
fixes #561
2015-11-24 08:51:06 +13:00
Sean McArthur
9c99e939a6 Merge pull request #693 from brycefisher/feat/access-control-allow-credentials
feat(headers): Add Access-Control-Allow-Credentials header
2015-11-22 08:47:46 -08:00
Bryce Fisher-Fleig
19348b892b feat(headers): Add Access-Control-Allow-Credentials header
There is only one acceptable value for this header, "true", so
there header struct is unit-like (no fields nor data inside). See
documentation and tests for more info. Case insensitive.

Closes #655
2015-11-22 00:53:16 -08:00
Sean McArthur
799698ca87 feat(headers): re-export CookiePair and CookieJar 2015-11-20 13:15:07 -08:00
Sean McArthur
81d42c964e chore(dependencies): update openssl to 0.7 and cookie to 0.2
Closes #686
2015-11-20 11:12:56 -08:00
Markus Unterwaditzer
f783e9913b feat(headers): Add Access-Control-Expose-Headers
Fix #673
2015-11-02 22:09:49 +01:00
Pyfisch
4c756a9304 style(headers): use regular doc-comments inside macros
A bug (rust-lang/rust#23812) in rustc prevented the use of normal
comments inside macros but this has been fixed.
2015-10-27 19:19:05 +01:00
Mike Dilger
341f8eae6e fix(headers): case insensitive values for Connection header
Closes #635
2015-08-28 10:36:54 +12:00
Sean McArthur
31f117ea08 fix(client): improve HttpReader selection for client Responses
Closes #436
2015-08-05 16:42:48 -07:00
ealasu
af062ac954 feat(headers): Content-Range header 2015-08-05 11:33:38 -07:00
Baptiste Darthenay
65ba136f02 Doc: moved blank line in right place.
http://ironframework.io/doc/iron/headers/struct.ContentType.html#examples
2015-07-15 10:39:18 +02:00
Patrick Walton
87de1b77bc feat(http): add optional serialization of common types via serde
This is behind a Cargo feature to avoid forcing downstream users to
depend on `serde`. It is needed for Servo IPC to work.
2015-07-10 17:45:08 -07:00