176 Commits

Author SHA1 Message Date
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
07cf414e17 fix(logging): adjust several logging messages
Closes #148
2014-11-28 18:03:37 -08:00
Sean McArthur
3cd9b10bcb feat(server): keep-alive!
Internals have been shuffled around such that Request and Reponse are
now given only a mutable reference to the stream, instead of being
allowed to consume it. This allows the server to re-use the streams if
keep-alive is true.

A task pool is used, and the number of the threads can currently be
adjusted by using the `listen_threads()` method on Server.

[breaking-change]
2014-11-20 21:40:55 -08:00
Jakob Gillich
f3e1baea9f fix(http): is_valid_method expects &-ptr 2014-11-19 22:07:11 +01:00
Jakob Gillich
0020ad1e97 TaskPool updates 2014-11-17 20:10:16 +01:00
Sean McArthur
3c10a8a191 feat(server): change Incoming to iterator over Connections
A connection is returned from Incoming.next(), and can be passed to a
separate thread before any parsing happens. Call conn.open() to get a
Result<(Request, Response)>.

BREAKING CHANGE
2014-11-10 13:55:11 -08:00
Jonathan Reem
a69b5ae166 Add a simple threaded hello world example. 2014-11-07 15:52:28 -08:00
Jonathan Reem
60af7c4565 (fix) fail! to panic! 2014-10-30 01:08:46 -07:00
Michael Hart
262a1658cf Remove debug crate
This fixes errors with latest 0.13.0-nightly as crate has been removed:

`error: can't find crate for ‘debug’`
2014-10-18 18:39:03 -04:00
Sean McArthur
e6329af74e Slice was changed to AsSlice in libstd 2014-10-13 18:37:14 -07:00
Sean McArthur
2f755a5694 move rendering of headers to the Headers object 2014-10-13 14:32:48 -07:00
Jonathan Reem
4115c0e219 Moved WriteStatus, Fresh, and Streaming in to the net module. 2014-09-10 17:16:13 -07:00
Jonathan Reem
d5c6f33c34 Update the client API to statically track headers and move constructors
The client Request now uses the same system as a server Response to track
the write status of headers, and the API has been updated accordingly.

Additionally, the Request constructors have been moved onto the Request object
instead of being top-level hyper functions, as this better namespaces the
client and Server.
2014-09-10 17:04:49 -07:00
Jonathan Reem
cfd5cf3c68 Split Server::listen into two methods to hack around ICE related to default type params
Trying to default the type parameters leads to an ICE and strange type errors.
I think this is just due to the experimental state of default type params and
this change can be rolled back when they are fixed.
2014-09-10 12:48:43 -07:00
Jonathan Reem
76a58940d8 Use trait objects and dynamic dispatch to abstract over NetworkStream
Server and client benchmarks show that this makes very little difference
in performance and using dynamic dispatch here is significantly more ergonomic.

This also bounds NetworkStream with Send to prevent incorrect implementations.

Allows the implementation of mock streams for testing and flexibility.

Fixes #5
2014-09-09 17:05:59 -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
622a18cd37 Fix concurrent server example for new Response representation. 2014-09-08 18:34:29 -07:00
Sean McArthur
e32845cefb Merge pull request #19 from reem/static-response-states
Statically track the status of a Response by using a Phantom Type
2014-09-08 18:27:13 -07:00
Jonathan Reem
ce61781cbd Added example of a concurrent server
Simple example that demonstrates how to create a concurrent
server on top of the primitives exposed by hyper.
2014-09-08 18:24:55 -07:00
Jonathan Reem
13bb07e02d Updated examples and benchmarks for new Response representation. 2014-09-08 16:52:27 -07:00
Jonathan Reem
872dcf758c Statically track the status of a Response by using a Phantom Type
Introduces two Phantom Types, Fresh and Streaming, which indicate the status
of a Response.

Response::start translates an Response<Fresh> into a
Response<Streaming> by writing the StatusCode and Headers.

Response<Fresh> allows modification of Headers and StatusCode, but does
not allow writing to the body. Response<Streaming> has the opposite privileges.
2014-09-08 16:52:24 -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
Jonathan Reem
3fbf3040cd Updated example for new Handler trait
This introduces a bit of complexity to the example,
mainly the use of the try_continue! macro for dealing
with errors, but I think this is an appropriate trade-off
as users of this library are likely to be framework authors
instead of end users.
2014-09-07 09:37:53 +02: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