Commit Graph

44 Commits

Author SHA1 Message Date
Sean McArthur
a5e6174efd fix(client): don't close stream until EOF
Closes #543
2015-05-23 15:11:44 -07:00
Sean McArthur
7e3858c962 perf(all): replace &str.to_string() with .to_owned() 2015-05-12 23:01:58 -07:00
Sean McArthur
a3637d5f73 refactor(all): adjust some logging 2015-05-09 22:18:05 -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
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
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
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
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
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
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
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
Sean McArthur
8c83a3358e feat(client): add a new Client struct with super powers
- Includes ergonomic traits like IntoUrl and IntoBody, allowing easy
usage.
- Client can have a RedirectPolicy.
- Client can have a SslVerifier.

Updated benchmarks for client. (Disabled rust-http client bench since it
hangs.)
2014-12-14 11:56:39 -08:00
Sean McArthur
fec030a21e rust upgrade 2014-12-02 13:12:04 -08:00
Sean McArthur
4263a01f1c convert to using Cow 2014-11-27 12:13:07 -08:00
Evgeny Rozaliev
c77cd3d3da (fix) unwrap() => into_inner() 2014-11-27 16:05:19 +03:00
Sean McArthur
486080b044 feat(client): add a status_raw value 2014-11-24 19:49:12 -08:00
Kyle Dewey
d7e8b8b117 Now using use along with enums, as per https://github.com/rust-lang/rust/pull/18973. 2014-11-19 22:03:41 +01:00
Sean McArthur
3b8c5cac1a fix(client): GET and HEAD shouldn't add Transfer-Encoding
Also adds an EmptyWriter, used for GET and HEAD requests,
which will return an io::ShortWrite error if the user ever tries
to write to a GET or HEAD request.

Closes #77
2014-11-09 20:56:59 -08:00
Sean McArthur
3cd7d72b07 split NetworkStream::connect to NetworkConnector 2014-10-31 15:49:26 -07:00
Sean McArthur
0ab52c9009 add bits to deal with Upgrade requests 2014-10-27 20:36:57 -07:00
Stanislav Panferov
d5e33ca9db (fix) abstract is now a reserved word. 2014-10-10 10:52:47 +04:00
Jonathan Reem
858a09304a Remove get and rename get_ref to get
Since `get_ref` (now `get`) takes `&self` there is no need
for a special cloning method.
2014-09-27 00:17:59 -04:00
Jonathan Reem
e85ae48e16 Update server and client for changes in Headers mutability. 2014-09-27 00:17:58 -04:00
Jonathan Reem
2aabf1b8e6 Rename rfc7230 to http to more clearly indicate its purpose. 2014-09-09 17:37:01 -07:00
Jonathan Reem
ed491655dd Use dynamic dispatch for client Request and Response through Box<NetworkStream>
Also adds a convenience `abstract` method to NetworkStream for creating
Box<NetworkStream + Send> from a NetworkStream.
2014-09-09 17:06:27 -07:00
Sean McArthur
0285fc2acc Abstract out NetworkStream
This introduces a new Trait, NetworkStream, which abstracts over
the functionality provided by TcpStream so that it can be easily
mocked and extended in testing and hyper can be used for
other connection sources.
2014-09-09 14:55:14 -07:00
Jonathan Reem
f2c09c5743 Split common headers into a submodule and into their own files
This is a more extensible place to put them and doesn't clutter up
header/mod.rs as much as the old scheme did.

Fixes #8
2014-09-08 16:20:50 -07:00
Sean McArthur
1ceb468ec3 add issue numbers to todos 2014-09-03 10:55:21 -07:00
Sean McArthur
b4b539091f use Buffered Readers and Writers 2014-09-02 14:14:56 -07:00
Sean McArthur
818fac4128 add some benches with other http libs 2014-09-02 12:06:16 -07:00
Sean McArthur
c905111f8c implementation 2014-09-01 18:39:24 -07:00