Commit Graph

1389 Commits

Author SHA1 Message Date
Sean McArthur
42e69e1f2e ssl for the client 2014-09-15 21:12:19 -07:00
Jonathan Reem
fdcd25356d Refactor Header representation to not store the raw representation
This disallows reparsing, but since that can be a significant source
of errors I think this is actually beneficial.

This also refactors to avoid storing the TypeId, though that is less
of a gain.
2014-09-15 19:21:21 -07:00
Jonathan Reem
2ca119fd80 Added Typeable dependency. 2014-09-15 19:21:17 -07:00
Sean McArthur
a0c4edb6e5 adjust representation of internal Items 2014-09-14 10:26:47 -07:00
Sean McArthur
c40b5b0c53 Request::with_stream to use a different NetWorkStream in Client
added benches for mocking out the tcp process
2014-09-11 08:26:03 -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
c2d9e34376 Change Server to contain a Vec of (ip, port) pairs to allow repeat listening
Expose Server::many for creating a Server that will listen on many (ip, port)
pairs.

Handler still receives a simple Iterator of (Request, Response) pairs.

This is a breaking change since it changes the representation of Listener,
but Handler and Server::http are unchanged in their API.

Fixes #7
2014-09-10 11:55:46 -07:00
Jonathan Reem
2aabf1b8e6 Rename rfc7230 to http to more clearly indicate its purpose. 2014-09-09 17:37:01 -07:00
Sean McArthur
b90341309f Merge pull request #29 from reem/network-stream
Abstract over NetworkStream using dynamic dispatch
2014-09-09 17:24:57 -07:00
Jonathan Reem
632250b431 Update benchmarks and introduce more default type params for remaining generics
The client benchmarks did not have to be changed at all for this whole
refactor, and the server benchmark only had to specify a single type parameter,
and only because it writes out the type of Listener, which is not normal
usage.
2014-09-09 17:06:27 -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
Jonathan Reem
8026867334 Deny missing documentation and all warnings for cleaner builds. 2014-09-09 17:06:23 -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
d11f1d5a4d Parse Transfer Encodings that we don't handle
We should not throw away information here, as downstream users
may want to handle alternative encodings.
2014-09-09 14:38:38 -07:00
Jonathan Reem
d02c24e1ee Provide Response::<Fresh>::deconstruct to deconstruct a Response.
This allows downstream frameworks by-value access to these fields,
letting them create their own Response abstractions out of hyper's
Response.
2014-09-08 18:37:38 -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
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
Sean McArthur
eaa3cb46ee todos 2014-09-07 20:17:32 -07:00
Sean McArthur
1926e82369 docs typos 2014-09-07 20:17:32 -07:00
Jonathan Reem
f9565a9dec Key Headers HashMap with SendStr instead of &'static str
This fixes an unsafe transmute that could cause use-after-frees
on collision resolution in the headers hash and avoids allocating
for cases where it is not necessary.

Fixes #12
2014-09-07 17:40:18 -07:00
Sean McArthur
2ac1305b18 Merge pull request #13 from reem/handler-iterator
Change the Handler trait to receive an Iterator of (Request, Response) pairs.
2014-09-07 10:49:25 -07:00
Sean McArthur
310789a73b Merge pull request #16 from reem/expose-raw-header
Add a get_raw method, which allows users to access the raw value of a header
2014-09-07 09:40:11 -07:00
Jonathan Reem
d3bca27e8a Add a get_raw method, which allows users to access the raw value of a header
This method is marked unsafe, as it should not be used in normal code
because it can easily invalidate header representations.

Fixes #10
2014-09-07 09:57:55 +02:00
Jonathan Reem
5f24bcecd4 Use an out-of-tree unsafe-any trait instead of a home-grown version.
This has the advantage of being separately checked, tested
and documented.
2014-09-07 09:49:10 +02:00
Jonathan Reem
c760ed063e Change the Handler trait to receive an Iterator of (Request, Response) pairs.
This allows downstream users to have total control of their concurrency
strategy, while also exposing a very nice, streaming interface for frameworks
to build on.

This also resolves issues surrounding the use of IoResult as the return type
of Handler::handle, because handlers now have complete control over how to
handle internal failure.

Fixes #3
Fixes #4
2014-09-07 09:18:20 +02:00
Sean McArthur
4d77477c83 add Date header 2014-09-03 14:14:44 -07:00
Sean McArthur
e2e93c5d5f add + 'static bounds to Header trait 2014-09-03 11:12:04 -07:00
Sean McArthur
592438b630 change headers to use static strs 2014-09-03 11:05:48 -07:00
Sean McArthur
307311f745 consume Server upon listen 2014-09-03 10:56:15 -07:00
Sean McArthur
1ceb468ec3 add issue numbers to todos 2014-09-03 10:55:21 -07:00
Sean McArthur
055a783ef0 adding a custom header to benches 2014-09-02 20:52:29 -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
8938726ed1 adding explicit bounds 2014-09-01 18:51:12 -07:00
Sean McArthur
c905111f8c implementation 2014-09-01 18:39:24 -07:00