Commit Graph

293 Commits

Author SHA1 Message Date
Sean McArthur
71ac65da5b refactor(http): move h1 and h2 into http module 2015-06-02 12:24:56 -07:00
Marko Lalic
d3e3a45760 refactor(client): use a Protocol to create a message for a Request 2015-06-02 14:34:13 +02:00
Marko Lalic
aa297f4532 refactor(client): use HttpMessage in Request and Response
BREAKING CHANGE: `hyper::client::request::Response` is no longer generic
over `NetworkStream` types. It no longer requires a generic type
parameter at all.
2015-06-02 14:34:13 +02:00
Marius Seritan
43e274cfce test(request): increasing test coverage of request module 2015-05-24 21:07:56 -07:00
Sean McArthur
69aa25fd0c Merge pull request #545 from hyperium/issue-543
fix(client): don't close stream until EOF
2015-05-23 17:22:38 -07:00
Sean McArthur
a5e6174efd fix(client): don't close stream until EOF
Closes #543
2015-05-23 15:11:44 -07:00
Marius Seritan
be041d915a feat(client): implement Default trait for client
Initial implementation of the default trait.
2015-05-15 22:35:42 -07:00
Sean McArthur
7e3858c962 perf(all): replace &str.to_string() with .to_owned() 2015-05-12 23:01:58 -07:00
Sean McArthur
1b318724a5 feat(net): remove mut requirement for NetworkConnector.connect()
BREAKING CHANGE: Any custom Connectors will need to change to &self in
  the connect method. Any Connectors that needed the mutablity need to
  figure out a synchronization strategy.

  Request::with_connector() takes a &NetworkConnector instead of &mut.
  Any uses of with_connector will need to change to passing &C.
2015-05-09 23:14:23 -07:00
Sean McArthur
7bc4e83ec2 Merge pull request #518 from mlalic/fix-client-ssl-verifier
fix(client): keep the underlying connector when setting an SSL verifier
2015-05-09 22:46:43 -07:00
Sean McArthur
390b9fa134 Merge pull request #520 from hyperium/conn-close
fix(client): dont call close() inside Request
2015-05-09 22:44:43 -07:00
Sean McArthur
3334fca278 fix(client): dont call close() inside Request
Only call close() in the Response, which should already return a
responding `Connection: close`.

Closes #519
2015-05-09 22:20:13 -07:00
Sean McArthur
a3637d5f73 refactor(all): adjust some logging 2015-05-09 22:18:05 -07:00
Marko Lalic
f4556d554f fix(client): keep the underlying connector when setting an SSL verifier
The client no longer drops the old `Connector` instance, along with its
entire context (such as the settings and pooled connections in the case
of a `Pool` connector); rather, it passes the SSL verifier on to the
`Connector` so that it uses it for any future connections that it needs
to establish.

A regression test is included.

Closes #495
2015-05-09 20:10:51 +02:00
Marko Lalic
a5d632b6ea feat(net): add set_ssl_verifier method to NetworkConnector trait
The commit includes an implementation of the new trait method for all
existing trait impls.

BREAKING CHANGE: Adding a new required method to a public trait is a
breaking change.
2015-05-09 20:10:51 +02:00
Sean McArthur
972b3a388a feat(error): add Ssl variant to hyper::Error
The errors from openssl were previously boxed into a
Box<std::error::Error>, which lost some specifics and made it difficult
to match against. To solve this, an `Ssl` variant is added to the
`Error` enum of hyper, and is returned when openssl returns specific
errors.

Closes #483

BREAKING CHANGE: Adds a variant to `hyper::Error`, which may break any
exhaustive matches.
2015-05-05 18:25:19 -07:00
Tshepang Lekhonkhobe
7ddea2791c docs(misc): fix typos caught by codespell 2015-05-06 02:34:07 +02: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
1e72a8ab3a feat(client): add a Connection Pool
This adds a connection pool to the Client that is used by default. It
accepts any other NetworkConnector, and simply acts as a
NetworkConnector itself. Other Pools can exist by simply providing a
custom NetworkConnector. This Pool is only used by default if you also
use the default connector, which is `HttpConnector`. If you wish to use
the Pool with a custom connector, you'll need to create the Pool with
your custom connector, and then pass that pool to the
Client::with_connector.

This also adds a method to `NetworkStream`, `close`, which can be used
to know when the Stream should be put down, because a server requested
that the connection close instead of be kept alive.

Closes #363
Closes #41
2015-04-29 12:58:28 -07:00
Sean McArthur
e814680b55 Merge pull request #473 from hyperium/docup
Docup
2015-04-22 15:45:09 -07:00
Sean McArthur
48a010ffd7 docs(client): add improved usage examples 2015-04-22 12:28:19 -07:00
Sean McArthur
a2aefd9a56 feat(client): accept &String as Body in RequestBuilder
BREAKING CHANGE: This removes the trait `IntoBody`, and instead using
  `Into<Body>`, as it's more idiomatic. This will only have broken code
  that had custom implementations of `IntoBody`, and can be fixed by
  changing them to `Into<Body>`.
2015-04-16 10:25:12 -07:00
Sean McArthur
8bc179fb51 feat(client): accept &String for a Url in RequestBuilder
adds an IntoUrl implementation for &String
2015-04-16 10:10:42 -07:00
Sean McArthur
0fb92ee735 feat(debug): add Debug impls for StatusClass, Server, and Listening 2015-04-16 10:04:51 -07:00
Sean McArthur
4f09b002ff feat(log): clean up logging 2015-04-15 21:08:52 -07:00
Brandon Sanderson
2f606c88bd feat(http): Implement Debug for HttpReader/Writer.
Also derives it for Responses, since that's easy now.
2015-04-08 18:03:08 -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
Sean McArthur
0f5858f379 fix(rustup): update to rust beta 2015-04-02 12:56:20 -07:00
Sean McArthur
dd5ee43750 chore(features): remove feature gate 'alloc' 2015-03-31 18:46:02 -07:00
Sean McArthur
6c31ea84e1 Merge pull request #401 from hyperium/packets
fix(http): read more before triggering TooLargeError
2015-03-28 11:37:43 -07:00
Jonathan Reem
dbee6af8df refactor(hyper): Remove the box_syntax feature gate. 2015-03-27 13:37:30 -07:00
Sean McArthur
cb59f609c6 fix(http): read more before triggering TooLargeError
This includes a custom BufReader, since the one in libstd doesn't allow
reading additional data into the buffer without consuming it. This is
required because some connections may send shorter packets, and so we
need to perform multiple reads. After each read, the contents of the
buffer are passed to httparse to see if have a valid message. If so, the
proper amount of bytes are consumed. The additional bytes are left in
the buffer since they are the beginning of the body.

The buffer in this BufReader also grows in size, compared to the libstd
which is sized once. This is because we start with a smaller buffer,
since the majority of messages will be able to include their head in a
packet or 2. Therefore, it's a wasteful performance hit to allocate the
maximum size for every message. However, some headers can be quite big,
and to allow for many of them to be set, we include a maximum size. Once
we've hit the maximum buffer size, and still haven't determined the end
of the headers, a HttpTooLargeError will be returned.

Closes #389
2015-03-27 10:52:07 -07:00
Kevin Butler
eee7a85d3c fix(rustup): static bounds required on Type definition, trivial_casts 2015-03-26 17:02:20 +00:00
Sean McArthur
d28bae3c91 refactor(client): remove explicit Send implementations from Request/Response 2015-03-13 19:54:34 -07:00
Sean McArthur
a2c6c4a25e Merge pull request #370 from hyperium/httparse
perf(http): changes http parsing to use httparse crate
2015-03-13 17:58:41 -07:00
Sean McArthur
b87bb20f0c perf(http): changes http parsing to use httparse crate
httparse is a http1 stateless push parser. This not only speeds up
parsing right now with sync io, but will also be useful for when we get
async io, since it's push based instead of pull.

BREAKING CHANGE: Several public functions and types in the `http` module
  have been removed. They have been replaced with 2 methods that handle
  all of the http1 parsing.
2015-03-13 16:56:13 -07:00
Camille TJHOA
602c1e27fd docs(client): fix #357 2015-03-04 13:48:09 +01:00
Sean McArthur
0fd6fcd7c7 feat(hyper): switch to std::io, std::net, and std::path.
All instances of `old_io` and `old_path` were switched to use the new
shiny `std::io`, `std::net`, and `std::path` modules. This means that
`Request` and `Response` implement `Read` and `Write` now.

Because of the changes to `TcpListener`, this also takes the opportunity
to correct the method usage of `Server`. As with other
languages/frameworks, the server is first created with a handler, and
then a host/port is passed to a `listen` method. This reverses what
`Server` used to do.

Closes #347

BREAKING CHANGE: Check the docs. Everything was touched.
2015-03-03 14:32:03 -08:00
Sean McArthur
4f5b97fefc fix(rustup): Send changes 2015-02-21 15:05:51 -08:00
Renato Zannon
1904c4561f fix(rustup): Add PhantomData markers to phantom type users
Necessary since [RFC 738](https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md).
2015-02-21 15:05:50 -08:00
Renato Zannon
039e984f68 fix(rustup): Remove uses of the obsolete &a[] syntax 2015-02-21 15:05:50 -08:00
Christian Stefanescu
f606b6039d fix(rustup): update io import, Writer::write
Make it build with the latest rust-nightly (2015-01-27)

Renamed io import to old_io.
Renamed Writer::write to Writer::write_all
2015-01-28 11:58:45 -08:00
Pyfisch
8d0e5bc302 refactor(headers): export all headers and utils directly under header
Currently headers are exported at many places. For example you can access
`Transfer-Encoding` header at `header`, `header::common` and
`header::common::transfer_encoding`. Per discussion on IRC with
@seanmonstar and @reem, all contents of headers will be exposed at `header`
directly. Parsing utilities will be exposed at `header::parsing`. Header
macros can now be used from other crates.

This breaks much code using headers. It should use everything it needs
directly from `header::`, encodings are exposed at `header::Encoding::`,
connection options are exposed at `header::ConnectionOption`.
2015-01-20 13:04:42 +01:00
Manish Goregaokar
bca9a53c66 feat(net): Move SSL verification to unboxed closures 2015-01-15 22:23:13 +05:30
Manish Goregaokar
af5778510d feat(net): Allow more generic SSL verification (fixes #244) 2015-01-14 19:29:48 +05:30
Sean McArthur
f7124bb8e2 rustup: sweeping fixes for all the changes in 1.0-alpha
- Some switches to u64 instead of usize
- For now, allow(unstable)
- use associated types for all the Network stuff
2015-01-10 21:29:27 -08:00
cyderize
122e94c8a6 Update for latest rust
Tracks rust nightly.

7 tests fail -- still finding source
2015-01-10 18:37:10 +11:00
Marko Lalic
2357995cc9 Add regression tests for chunked response parsing
The tests assert that `Transport-Encoding: chunked` responses are
correctly handled both when the chunk sizes are valid, as well as
invalid.
2015-01-06 22:15:18 +01:00
Jonathan Reem
93fcd05b9d Miscellaneous fixes and test updates for all the other changes
- http::LINE_ENDING is now an &'static str
2015-01-06 01:15:47 +01:00