Commit Graph

465 Commits

Author SHA1 Message Date
Sean McArthur
f8776f4c24 Merge pull request #312 from reem/acceptor-pool
feat(server): Rewrite the accept loop into a custom thread pool.
2015-02-14 17:49:25 -08:00
Sean McArthur
27b4573db1 Merge pull request #299 from hugoduncan/feature/add-accept-language
feat(headers): add AcceptLanguage header
2015-02-14 16:09:36 -08:00
Jonathan Reem
e623cab7cb Merge pull request #318 from hyperium/revert-310-server-request-drop
Revert "fix(server): Drain requests on drop."
2015-02-14 15:38:08 -08:00
Hugo Duncan
20a585e30b feat(headers): add AcceptLanguage header
Adds header support for Accept-Language, using a struct for the primary
and sub components of the language.
2015-02-14 18:24:52 -05:00
Jonathan Reem
783ababb13 revert(server): "fix(server): Drain requests on drop." 2015-02-14 15:14:59 -08:00
Jonathan Reem
361e4511e1 Merge pull request #310 from hyperium/server-request-drop
fix(server): Drain requests on drop.
2015-02-14 14:36:46 -08:00
Jonathan Reem
3528fb9b01 feat(server): Rewrite the accept loop into a custom thread pool.
This is a modified and specialized thread pool meant for
managing an acceptor in a multi-threaded way. A single handler
is provided which will be invoked on each stream.

Unlike the old thread pool, this returns a join guard which
will block until the acceptor closes, enabling friendly behavior
for the listening guard.

The task pool itself is also faster as it only pays for message passing
if sub-threads panic. In the optimistic case where there are few panics,
this saves using channels for any other communication.

This improves performance by around 15%, all the way to 105k req/sec
on my machine, which usually gets about 90k.

BREAKING_CHANGE: server::Listening::await is removed.
2015-02-14 13:54:57 -08:00
Sean McArthur
6eeed6d48f Merge pull request #313 from hyperium/if-match
feat(headers): add IfMatch header
2015-02-14 12:00:52 -08:00
Hugo Duncan
5df06d4465 feat(headers): add IfMatch header
Add support for the If-Match http header.
2015-02-14 11:59:31 -08:00
Sean McArthur
3d0f423eb2 fix(server): Drain requests on drop.
If a client sent an illegal request (like a GET request with a message
body), or if there was a legal request with a body but the Handler
didn't read all of it, the remaining bytes would be left in the stream.
The next request to come from the same client would error, as the server
would confuse the remaining bytes, and think the request was malformed.

Fixes #197
Fixes #309
2015-02-14 11:20:03 -08:00
Sean McArthur
f554c09e12 Merge pull request #311 from hyperium/status-ng
feat(header): Support arbitary status codes
2015-02-13 19:04:16 -08:00
Pyfisch
7397853148 feat(header): Support arbitary status codes
As discussed in #177 hyper must support status code outside the
standard range for compatibility reasons.

BREAKING CHANGE: This removes unregistered status codes from the enum. Use
`FromPrimitive` methods to create them now. StatusCode and StatusClass can no
longer be casted to `u16`, use `ToPrimitive` methods now.
For example `status.to_u16().unwrap()` to get the status code number.
2015-02-13 18:59:14 -08:00
Sean McArthur
11f10ccdf2 v0.1.12 2015-02-13 12:28:43 -08:00
Sean McArthur
db83e0490b chore(rustup): fix std::env changes 2015-02-13 11:19:19 -08:00
Sean McArthur
2afa96c923 chore(rustup): add feature for path 2015-02-12 16:03:56 -08:00
Sean McArthur
2bd2af11a1 Merge pull request #308 from frewsxcv/deprecated-example
chore(examples): Stop using deprecated std::os::args in example
2015-02-11 22:28:05 -08:00
Corey Farwell
00e46d7cda chore(examples): Stop using deprecated std::os::args in example
As per this compiler warning

"warning: use of deprecated item: use std::env::args() instead, #[warn(deprecated)] on by default"
2015-02-11 23:11:14 -05:00
Sean McArthur
ddb85c4913 Merge pull request #307 from cyndis/fix/ssleof
fix(net): don't stop the server when an SSL handshake fails with EOF
2015-02-11 11:47:48 -08:00
Mikko Perttunen
55f1266089 fix(net): don't stop the server when an SSL handshake fails with EOF
HttpAcceptor::accept()'s HTTPS logic passes IO errors from the underlying
SSL stream directly to the caller. Furthermore, the caller uses the
EndOfFile error code to detect that the server should stop accepting
connections. This means that if the TCP connection was succesfully
accepted, but an EOF condition was detected during the handshake, the
server will stop accepting connections and quit. This allows for a
trivial denial of service attack and can happen accidentally as well.

Change HttpAcceptor::accept such that if the TCP stream underlying
the SSL stream returns an IoError error, a ConnectionAborted IoError
is returned instead. This allows distinguishing between IoErrors from
the acceptor and the stream. The original error reason is stored in the
detail field.
2015-02-11 21:33:48 +02:00
Jonathan Reem
3e951c9723 Merge pull request #306 from ctjhoa/master
docs(readme): Make the README client example work
2015-02-10 14:01:09 -08:00
Camille TJHOA
b5a6175bf5 docs(readme): Make the README client example work
`res` needs to be mutable
2015-02-10 22:44:00 +01:00
Sean McArthur
e6cae3cdaf Merge pull request #302 from fmendez/add-if-not-match-header
Add If-None-Match header
2015-02-07 13:45:27 -08:00
Fernando Mendez
318b067a06 feat(headers): Add If-None-Match header field
Add the HTTP/1.1 `If-None-Match` header field makes the request method conditional
on a recipient cache or origin server either not having any current
representation of the target resource, when the field-value is "*",
or having a selected representation with an entity-tag that does not
match any of those listed in the field-value.

Closes #238
2015-02-07 16:52:12 -04:00
Sean McArthur
f836ee89c1 v0.1.11 2015-02-06 22:10:17 -08:00
Sean McArthur
6aa6605e55 Merge pull request #296 from hugoduncan/feature/factor-entity-tag
Factor out EntityTag from Etag header
2015-02-06 22:01:27 -08:00
Sean McArthur
93ac2c8e46 Merge pull request #289 from hyperium/opt-cell
refactor(headers): switch from MuCell to OptCell
2015-02-06 21:53:38 -08:00
Sean McArthur
d7fe8c307a refactor(headers): switch from MuCell to OptCell
It turns out, we don't need capabilities of MuCell (or even RefCell).
We don't to have sophisticated interior mutability. We don't ever lend
out references that may be mutated later. Instead, if there is no value
to lend, then we generate the value, require interior mutability to save
the value internally, and then we return a reference. We never ever
change a value once it's been generated. It can be changed, but only via
&mut self methods, where we can safely reason about mutability.

This means we don't need keep borrow checking code at runtime, which
helps performance. We also are able to reduce the amount of unsafe
transmutes. The internal API more safely constrains the usage of unsafe,
enforcing our invariants, instead of shotgunning unsafe usage with Refs
and promising we're doing it correctly.

On a machine with lower memory (1GB):

    Before:
    test bench_mock_hyper ... bench:    251772 ns/iter (+/- 128445)

    After:
    test bench_mock_hyper ... bench:    152603 ns/iter (+/- 25928)

On a machine with more memory, weaker CPU:

    Before:
    test bench_mock_hyper ... bench:    129398 ns/iter (+/- 51740)

    After:
    test bench_mock_hyper ... bench:    115935 ns/iter (+/- 28555)

Closes #252
2015-02-06 21:47:29 -08:00
Hugo Duncan
28fd5c81f5 refactor(headers): factor out EntityTag from Etag
Allow use of EntityTag in other headers that use entity tags.

BREAKING CHANGE: for any consumers of the Etag header, since the entity
tag is now in a tuple.
2015-02-06 19:48:29 -05:00
Sean McArthur
e9af13c3a6 Merge pull request #297 from hugoduncan/feature/add-if-unmodified-since
feat(headers): add IfUnmodifiedSince header
2015-02-06 16:30:42 -08:00
Hugo Duncan
b5543b6752 feat(headers): add IfUnmodifiedSince header
This adds support for the If-Unmodified-Since header, and is a trivially
edited version of IfModifiedSince.
2015-02-06 18:42:52 -05:00
Sean McArthur
04e865c1cf Merge pull request #294 from xymostech/patch-2
fix(readme): Make the README client example work
2015-02-06 10:17:18 -08:00
Emily Eisenberg
9b5d6aab7e fix(readme): Make the README client example work
`res` needs to be unwrapped, we want to print out `body`, and `res` doesn't need to be mutable.
2015-02-06 10:09:23 -08:00
Sean McArthur
c2784bca7a docs(git): push contributors list to humans.txt 2015-02-05 20:01:19 -08:00
Sean McArthur
1f5547c4b7 v0.1.10 2015-02-03 19:09:06 -08:00
Sean McArthur
22a80a9308 Merge pull request #292 from hyperium/rustup
fix(rustup): update FromStr
2015-02-03 19:01:32 -08:00
Peter Atashian
742081c8cf fix(rustup): update FromStr
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-02-03 18:57:24 -08:00
Sean McArthur
eee4625686 Merge pull request #290 from hyperium/max-headers
fix(headers): add limit to maximum headers that should be parsed
2015-02-03 18:37:22 -08:00
Sean McArthur
f18a8fb76f fix(headers): add limit to maximum header size that should be parsed
Closes #256
2015-02-03 11:06:17 -08:00
Sean McArthur
c983ebf3ce chore(cargo): add keywords to Cargo.toml 2015-02-02 10:29:36 -08:00
Sean McArthur
05a3a6b70b fix(rustup): fix unused_feature warning in example server 2015-02-01 20:39:09 -08:00
Sean McArthur
3bf4c5e7ae Merge pull request #288 from hyperium/rustup
fix(rustup): switch to unstable features
2015-01-31 12:27:40 -08:00
Sean McArthur
3af8b687d4 fix(rustup): switch to unstable features 2015-01-31 12:15:44 -08:00
Sean McArthur
4ad4c491d3 v0.1.9 2015-01-28 12:17:42 -08:00
Sean McArthur
fcefda091f Merge pull request #287 from hyperium/rustup
fix(rustup): update io import, Writer::write
2015-01-28 12:10:05 -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
Sean McArthur
537d691d61 Merge pull request #283 from reem/dont-print-q=1
fix(headers): Don't display q if q=1 in quality item.
2015-01-27 23:07:18 -08:00
Jonathan Reem
91df2441a0 fix(headers): Don't display q if q=1 in quality item.
Fixes #281
2015-01-28 00:54:38 -05:00
Sean McArthur
93821fc731 chore(git): update changelog.md 2015-01-27 18:30:33 -08:00
Jonathan Reem
9a23721c43 Merge pull request #282 from hyperium/is-status-class
feat(status): add is_<status_class>() methods to StatusCodes
2015-01-27 21:21:48 -05:00
Sean McArthur
2d55a22e73 feat(status): add is_<status_class>() methods to StatusCodes 2015-01-27 18:07:23 -08:00