Commit Graph

1221 Commits

Author SHA1 Message Date
Sean McArthur
d966d595e6 chore(github): add pull request template 2017-01-25 11:42:40 -08:00
Sean McArthur
44f2bc6d00 refactor(http): add From<Vec<u8>> impl for MemBuf 2017-01-25 11:05:58 -08:00
Sean McArthur
e3ef866a31 refactor(http): allow MemSlice to be sliced to make copies 2017-01-24 18:36:49 -08:00
Sean McArthur
cfcbd8c96b fix(http): keep flushing until WOULDBLOCK is received 2017-01-23 23:57:43 -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
0e332c66f2 refactor(http): adjust socket eof debug log 2017-01-23 22:50:42 -08:00
Sean McArthur
8597c55a13 refactor(http): adjust debug logs 2017-01-23 22:48:35 -08:00
Sean McArthur
8cd89bed86 refactor(header): improve debug view of Headers 2017-01-23 22:48:35 -08:00
Sean McArthur
0385427b53 Merge pull request #1030 from M3rs/remove_vec
refactor(uri): Remove vec in uri parsing

Closes #1029
2017-01-23 16:54:03 -08:00
Andy Moran
18bcc4e047 refactor(uri): Remove vec in uri parsing
Remove vec allocations in uri parsing. Additionally, change tests
to check the port.

https://github.com/hyperium/hyper/issues/1029
2017-01-23 22:35:50 +00:00
Sean McArthur
8f8b8618cd refactor(examples): remove log crate from server example 2017-01-23 13:31:39 -08:00
Sean McArthur
a126d2234e Merge pull request #1027 from M3rs/refactor_uri
Refactor(uri): Remove usage of Url parse in Uri #1022
2017-01-23 12:58:21 -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
Sean McArthur
7d400398ab refactor(header): only import langtag macro for tests 2017-01-23 11:18:48 -08:00
M3rs
04560dfe24 refactor(uri): Improve parse_authority safety
Improve parse_authority safety with match, replace unwrap.

Also, refactor code in contains("://") block using result from the
parse_authority to also use match.

https://github.com/hyperium/hyper/issues/1022
2017-01-23 12:26:08 -06:00
M3rs
8faf5b8bb1 refactor(uri): Add errors to scheme uri
Add errors to scheme uri (contains "://").

Check for:
- Valid schemes (ftp, gopher, http, https, ws, wss)
- Invalid schemes (blob, file), or anything else -> Err(Error::Method)
- Authority is not empty (i.e. "http://")

https://github.com/hyperium/hyper/issues/1022
2017-01-22 11:38:45 -06:00
M3rs
37b26e21e8 refactor(uri): Add default path for absolute-form
Add default path ("/") for absolute-form, even if not included.

This change assumes self.scheme().is_some() indicates that the Uri
is in absolute-form.

Issue:
https://github.com/hyperium/hyper/issues/1022
2017-01-22 10:51:06 -06:00
M3rs
55d13a9afd refactor(uri): Remove extra authority logic
Remove extra logic in authority getter method which handles
default ports.
2017-01-21 21:20:24 -06:00
M3rs
4f5327afd4 refactor(uri): Remove Url parse
Remove usage of Url parse in Uri in order to improve performance.

https://github.com/hyperium/hyper/issues/1022
2017-01-20 23:41:09 -06:00
Jake Goulding
ab254c9103 chore(cargo): add categories to Cargo.toml 2017-01-20 12:04:57 -08:00
Sean McArthur
9f0a537b7b Merge pull request #1021 from fmonjalet/fix-uri-parsing
fix(uri): fix panic when uri contain default port
2017-01-20 12:03:18 -08:00
Florent Monjalet
594ea65420 fix(uri): fix panic when uri contain default port
Parsing "http://host:80" caused panic (index out of bound) because the
authority end index was computed with the original uri but the uri
stored for later used was sanitized by `Url::parse()` to "http://host"

The fix computes the autority end index with the actual uri used (the
one from `Url::parse()`). Two tests have been added.
2017-01-20 17:17:33 +01:00
Sean McArthur
81f64b4af5 chore(travis): remove extra echos from travis.yml 2017-01-19 19:39:31 -08:00
Sean McArthur
c4572121fa chore(travis): update travis gh-pages token 2017-01-19 18:23:19 -08:00
Sean McArthur
431420138e Merge branch 'docs-deploying' 2017-01-19 17:46:15 -08:00
Sean McArthur
b57a7a3df2 chore(travis): fix deploying docs after successful travis on master 2017-01-19 17:35:41 -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
Alex Crichton
f45e9c8e4f refactor(server): expose Http that implements ServerProto
The main changes are:

* The entry point is how `Http`, the implementation of `ServerProto`.
  This type has a `new` constructor as well as builder methods to
  configure it.

* A high-level entry point of `Http::bind` was added which returns a
  `Server`. Binding a protocol to a port requires a socket address
  (where to bind) as well as the instance of `NewService`. Internally
  this creates a core and a TCP listener.

* The returned `Server` has a few methods to learn about itself, e.g.
  `local_addr` and `handle`, but mainly has two methods: `run` and
  `run_until`.

* The `Server::run` entry point will execute a server infinitely, never
  having it exit.

* The `Server::run_until` method is intended as a graceful shutdown
  mechanism. When the provided future resolves the server stops
  accepting connections immediately and then waits for a fixed period of
  time for all active connections to get torn down, after which the
  whole server is torn down anyway.

* Finally a `Http::bind_connection` method exists as a low-level entry
  point to spawning a server connection. This is used by `Server::run`
  as is intended for external use in other event loops if necessary or
  otherwise low-level needs.

BREAKING CHANGE: `Server` is no longer the pimary entry point. Instead,
  an `Http` type is created  and then either `bind` to receiver a `Server`,
  or it can be passed to other Tokio things.
2017-01-18 14:09:20 -08:00
Sean McArthur
39a53fcd33 Merge pull request #1014 from hyperium/next-uri
feat(uri): redesign RequestUri type into Uri
2017-01-17 17:44:18 -08:00
Sean McArthur
8b8ed46e56 Merge pull request #1015 from hyperium/unflaky
test(client): disable flaky disconnect test
2017-01-17 17:43:46 -08:00
Sean McArthur
49e281d086 test(client): disable flaky disconnect test 2017-01-17 17:25:55 -08:00
Guillaume Gomez
9036443e6b feat(uri): redesign RequestUri type into Uri
Closes #1000

BREAKING CHANGE: The name of `RequestUri` has changed to `Uri`. It is no
  longer an `enum`, but an opaque struct with getter methods.
2017-01-17 16:46:24 -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
1868f8548d refactor(http): remove buffer, use WriteBuf 2017-01-16 18:56:36 -08:00
Kornelijus Survila
6e4739f918 fix(http): Fix heap corruption in http::buffer::grow_zerofill
Fixes #1010
2017-01-16 14:24:09 -08:00
Sean McArthur
e4232dd0d8 test(client): sleep disconnect test to reduce flakiness
Closes #1003
2017-01-16 12:58:06 -08:00
Sean McArthur
fef401921c chore(travis): only test integration benches, not run full benchmarks 2017-01-16 12:46:19 -08:00
Sean McArthur
1520d97ec1 chore(changelog): update changelog from 0.10.x 2017-01-16 10:53:38 -08:00
Sean McArthur
f0ab2b6aed feat(header): add Encoding::Brotli variant
BREAKING CHANGE: This adds a new variant to the `Encoding` enum, which
  can break exhaustive matches.
2017-01-16 10:50:36 -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
0a58f7e3b5 chore(travis): fix docs publish script 2017-01-16 10:50:35 -08:00
Sean McArthur
2f721c7f05 chore(travis): check for doc directory before building extra docs 2017-01-16 10:50:35 -08:00
Sean McArthur
0686c81c57 refactor(error): turn Void from an empty enum to a struct 2017-01-16 10:50:35 -08:00
Sean McArthur
ff84959f83 chore(lib): bump version to 0.11.0-a 2017-01-16 10:50:35 -08:00
Sean McArthur
be461b4663 perf(http): introduce MemBuf, a shared read buffer 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
e23689122a Merge pull request #989 from d-unseductable/docs/response_set_status
docs(server): fix Response::set_status() documentation
2017-01-08 20:16:39 -08:00
Dmitry Gritsay
334c4800bb docs(server): fix Response::set_status() documentation 2017-01-07 15:01:37 +02:00