Commit Graph

173 Commits

Author SHA1 Message Date
Nick Gonzales
864d3e27a4 refactor(http): merge Request and Response from server and client
Request and Response are now visible from:
- hyper::{Request, Response}
- hyper::server::{Request, Response}
- hyper::client::{Request, Response}
They truly exist in the http module, but are re-exported to reduce the number of breaking changes.

request::new and response::new were renamed to ::from_wire to reduce confusion with Request::new
and Response::new. See issue #1126

Request now has an optional Body, because not all requests have bodies.
Use body_ref() to determine if a body exists.
Use body() to take the body, or construct one if no body exists.

Closes #1155

BREAKING CHANGE: Response::body() now consumes the response
2017-05-01 14:22:07 -06:00
Ran Benita
f382f45e65 refactor(lib): use try_nb! from tokio_io, not tokio_core
tokio_core::io is deprecated, and the try_nb! conceptually belongs to
that module. It is also available in tokio_io, so use that instead.
2017-04-30 14:36:42 +03:00
Sean McArthur
f05a58a1b2 chore(travis): set minimum rust version 2017-04-10 15:09:54 -07:00
Sean McArthur
4fb7e6ebc6 feat(lib): remove extern Url type usage
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
  `Client` API has had it replaced with `hyper::Uri`.

  This also means `Error::Uri` has changed types to
  `hyper::error::UriError`.

  The type `hyper::header::parsing::HTTP_VALUE` has been made private,
  as an implementation detail. The function `http_percent_encoding`
  should be used instead.
2017-03-21 11:03:57 -07:00
Alex Crichton
8554904dc9 refactor(lib): convert usage of tokio_core::io to tokio_io
This commit updates to the most recent versions (released today) of the various
Tokio libraries in use. Namely the `tokio_core::io` module has now been
deprecated in favor of an external `tokio-io` crate. This commit pulls in that
crate and uses the `AsyncRead + AsyncWrite` abstraction instead of `Io` from
tokio-core.

BREAKING CHANGE: Any external types that were using that had implemented `Io` will need to 
  implement `AsyncRead + AsyncWrite` from tokio_io.
2017-03-17 17:31:44 -07:00
Sean McArthur
65b3e08f69 feat(http): use the bytes crate for Chunk and internally 2017-03-01 14:15:47 -08:00
Guillaume Gomez
5a4bd497c9 fix(Uri): Reexport Uri struct publicly 2017-02-09 15:25:55 +01:00
Sean McArthur
cca798a09e fix(header): deprecate HeaderFormatter 2017-01-30 12:20:30 -08:00
Josh
5c890321ee feat(lib): export Method::Put at top level 2017-01-25 11:43:56 -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
7d400398ab refactor(header): only import langtag macro for tests 2017-01-23 11:18:48 -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
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
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
81e6e98d80 docs(guide): adjust styles of the guides 2016-07-26 08:55:08 -07:00
Sean McArthur
12c69b5dd0 docs(guide): add meat to the Server Guide
Closes #806
2016-07-25 20:23:44 -07:00
Sean McArthur
e2264530e7 Merge pull request #864 from hyperium/less-deps
refactor(header): internalize traitobject and typeable
2016-07-14 20:36:43 -07:00
Sean McArthur
3e66377979 refactor(header): internalize traitobject and typeable 2016-07-14 17:27:59 -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
Sean McArthur
ad9c580e9a fix(lib): make ControlError public 2016-06-14 11:24:28 -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
Sean McArthur
01160abd92 feat(ssl): enable hostname verification by default for OpenSSL
Additionally disables SSLv2 and SSLv3, as those are universally considered
unsafe.

Closes #472
2016-05-08 10:04:37 -07:00
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
Steven Fackler
f37315b270 feat(net): Add Ssl impls for security-framework
Cloese #755
2016-04-16 16:20:52 -07:00
Sean McArthur
b872969880 fix(timeouts): remove rust #![feature] for socket timeouts 2015-09-16 14:30:12 -07:00
Sean McArthur
0455663a98 fix(nightly): remove feature flag for duration 2015-08-12 14:39:37 -07:00
Sean McArthur
7d1f154cb7 feat(net): add socket timeouts to Server and Client
While these methods are marked unstable in libstd, this is behind a
feature flag, `timeouts`. The Client and Server both have
`set_read_timeout` and `set_write_timeout` methods, that will affect all
connections with that entity.

BREAKING CHANGE: Any custom implementation of NetworkStream must now
  implement `set_read_timeout` and `set_write_timeout`, so those will
  break. Most users who only use the provided streams should work with
  no changes needed.

Closes #315
2015-07-27 09:57:59 -07: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
Sean McArthur
5994a6f8b4 fix(lint): change deny(missing_docs) to only apply for tests
Closes #600
2015-07-08 10:23:37 -07:00
Marko Lalic
37e55944cf test(hyper): assert that error::Error is Send + Sync
This is a regression test for #580.
2015-06-26 14:53:58 +02:00
Pyfisch
99ff7e6257 feat(langtags): use true language tags in headers
Make hyper dependant on rust-language-tags providing complete parsing
and formatting of language tags. Remove builtin solution for simple
tags.

BREAKING CHANGE: AcceptLanguage and ContentLanguage use LanguageTag now,
Language removed from Hyper.
2015-06-23 20:15:47 +02:00
Sean McArthur
53bba6eb7f feat(ssl): redesign SSL usage
BREAKING CHANGE: Server::https was changed to allow any implementation
  of Ssl. Server in general was also changed. HttpConnector no longer
  uses SSL; using HttpsConnector instead.
2015-06-20 14:58:58 -07:00
Marko Lalic
aee7c991e6 docs(hyper): fix html root url
The HTML root URL is not supposed to point at the index resource, but
represent the path that can be used to construct the full URL of the
crate's components.
2015-06-17 17:42:57 +02:00
Sean McArthur
64e47b4bbd feat(client): impl Sync for Client
Connector::connect already used &self, and so would require
synchronization to be handled per connector anyway. Adding Sync to the
Client allows users to setup config for a Client once, such as using a
single connection Pool, and then making requests across multiple
threads.

Closes #254

BREAKING CHANGE: Connectors and Protocols passed to the `Client` must
  now also have a `Sync` bounds, but this shouldn't break default usage.
2015-06-12 11:19:54 -07:00
Sean McArthur
71ac65da5b refactor(http): move h1 and h2 into http module 2015-06-02 12:24:56 -07:00
Marko Lalic
f0fe2c5a83 feat(http2): implement message API for HTTP/2 2015-06-02 15:44:12 +02:00
Marko Lalic
3122ffefc2 feat(http2): add dependency on solicit 2015-06-02 14:34:13 +02:00
Marko Lalic
ecb713f849 feat(client): implement HttpMessage for HTTP/1.1 2015-06-02 14:34:13 +02:00
Marko Lalic
289fd02b55 feat(client): add HttpMessage trait 2015-06-02 14:34:13 +02:00
Sean McArthur
a6dd9c8476 refactor(lib): macro_use the mime! macro 2015-05-11 18:48:00 -07:00
Sean McArthur
9ba074d150 refactor(error): remove redundant parts of error names
The old names followed the old style of including the module name and
"Error" in each variant. The new style is to refer to an error from its
owning module, and variants are now scoped to their enum, so there's no
need to include the enum name in the variant name.

BREAKING CHANGE: The terms `Http` and `Error` have been removed from the Error
  type and its variants. `HttpError` should now be accessed as `hyper::Error`,
  and variants like `HttpIoError` should be accessed as `Error::Io`.
2015-05-05 11:53:09 -07:00
Sean McArthur
8198f41ec0 docs(lib): add links to main modules 2015-04-22 12:27:33 -07:00
Sean McArthur
55b37f0148 test(beta): enable testing on beta rustc 2015-04-15 11:59:23 -07:00
Sean McArthur
139a51f1c3 feat(client): remove generic parameter for Connector
Closes #379

BREAKING CHANGE: For people using the default HttpConnector and Client,
    everything should continue to just work. If the Client has been
    used with a generic parameter, it should be removed.

    However, there were some breaking changes to the internals of
    NetworkConnectors. Specifically, they no longer return a
    NetworkStream, but instead a Into<Box<NetworkStream + Send>>. All
    implementations of NetworkStream should continue to just work,
    however.

    Possible breakages could come from the stricter usage of Send
    throughout the Client API.
2015-04-03 18:36:13 -07:00
Sean McArthur
5c2de29a81 chore(stability): remove core feature gate 2015-04-02 17:32:04 -07:00
Jonathan Reem
320d10d50d chore(all): Move downcasting to a stable implementation. 2015-04-02 13:30:41 -07:00
Sean McArthur
ccd4814e69 chore(stability): remove into_cow feature gate 2015-04-02 13:01:49 -07:00
Sean McArthur
0f5858f379 fix(rustup): update to rust beta 2015-04-02 12:56:20 -07:00