Commit Graph

2495 Commits

Author SHA1 Message Date
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
4eb48ab799 Merge pull request #30 from reem/dont-lose-transfer-encoding
Parse Transfer Encodings that we don't handle
2014-09-09 16:05:26 -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
Sean McArthur
a8d7b681da Merge pull request #28 from reem/fix-server-bench
Fix server benchmark for Response representation changes.
2014-09-09 13:52:28 -07:00
Jonathan Reem
a6096e8499 Fix server benchmark for Response representation changes. 2014-09-09 12:00:37 -07:00
Sean McArthur
29cf174a06 Merge pull request #22 from reem/bench-server
Benchmark hyper server against rust-http server.
2014-09-09 10:04:56 -07:00
Sean McArthur
2ae521de0b Merge pull request #26 from reem/expand-travis
Expand travis to build docs and run benchmarks
2014-09-08 22:42:51 -07:00
Jonathan Reem
349196e566 Benchmark hyper server against rust-http server.
Adds a benchmark for testing the speed of hyper's server.

Due to limitations of rust-http, `cargo bench` now needs to be
killed after running because there is no way to kill a rust-http
server after you start it.
2014-09-08 22:34:06 -07:00
Jonathan Reem
7c74a29cd0 Expand travis to compile benchmarks 2014-09-08 21:55:19 -07:00
Sean McArthur
d171d1c04c Merge pull request #21 from reem/response-parts
Provide Response::<Fresh>::deconstruct to deconstruct a Response.
2014-09-08 19:34:32 -07:00
Sean McArthur
7c7a26803f Merge pull request #24 from reem/fix-concurrent-server
Fix concurrent server example for new Response representation.
2014-09-08 18:39:43 -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
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
Sean McArthur
5a98d16b8e Merge pull request #23 from reem/concurrent-example
Added example of a concurrent server
2014-09-08 18:26:51 -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
Sean McArthur
77be77a6c1 Merge pull request #20 from reem/header-submodules
Split common headers into a submodule and into their own files
2014-09-08 16:45:16 -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
fd6b014e7e fix benches/client with new Handler 2014-09-08 09:12:49 -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
Sean McArthur
fcf2863c0f Merge pull request #14 from reem/string-headers
Key Headers HashMap with SendStr instead of &'static str
2014-09-07 20:01:39 -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
Sean McArthur
0758cf14ad Merge pull request #15 from reem/use-outside-unsafe-any-trait
Use an out-of-tree unsafe-any trait instead of a home-grown version.
2014-09-07 09:30:52 -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
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
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
7e223932f4 add docs link to readme 2014-09-02 20:51:57 -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
Sean McArthur
8865516816 init 2014-08-30 14:18:28 -07:00