Commit Graph

495 Commits

Author SHA1 Message Date
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
7235d3f74a Merge pull request #332 from pyfisch/improvquality
refactor(headers): Use u16 based newtype for quality value
2015-02-28 23:12:58 -05:00
Pyfisch
8f6ce453de refactor(headers): Use u16 based newtype for quality value
Using floating point numbers is problematic because comparison is inexact.
They also take more space than integral numbers in this case.

Add `FromPrimitve`, `ToPrimitive` and `Default` traits to quality newtype.

Closes: #330

BREAKING_CHANGE: Replace f32 quality values in quality items with a
Quality(u16) newtype. Valid values are from 0 to 1000.
2015-02-28 19:44:34 +01:00
Sean McArthur
b1b8bf1db7 v0.2.1 2015-02-27 06:01:44 -08:00
Sean McArthur
656552bf51 Merge pull request #340 from globin/rustup-4db0b3246-2015-02-25
Update to 4db0b3246 2015-02-25
2015-02-27 08:46:53 -05:00
Robin Gloster
1b6e6a040f fix(rustup): str.split and associated type changes 2015-02-27 13:33:21 +01:00
Jonathan Reem
9998417fe8 docs(README): Fix the example in the README. 2015-02-25 19:57:15 -08:00
Sean McArthur
3606f4aed8 Merge pull request #337 from AaronM04/master
Fixes compilation errors with latest rust
2015-02-25 22:06:17 -05:00
Aaron Miller
63910438c6 docs(client,server): fix compilation errors with latest Rust
Fix compilation errors relating to mutable borrowing the status
code from an immutably borrowed response. Also add the `extern crate
hyper` and appropriate `use` lines.
2015-02-25 13:29:18 -08:00
Jonathan Reem
0185afea91 Merge pull request #331 from filsmick/master
Add remove_raw method and corresponding test
2015-02-22 15:53:25 -08:00
filsmick (Yohaï Berreby)
4f576780c2 feat(headers): add remove_raw method and corresponding test
It was previously impossible to remove a header set by set_raw()

Closes #326
2015-02-22 16:16:39 +01:00
Sean McArthur
41fd8de243 v0.2.0 2015-02-21 15:15:09 -08:00
Sean McArthur
b985d85a5d Merge pull request #329 from hyperium/324
Rustup
2015-02-21 18:12:49 -05:00
Sean McArthur
4f5b97fefc fix(rustup): Send changes 2015-02-21 15:05:51 -08:00
Renato Zannon
98b8c4b137 fix(rustup): CowString is gone 2015-02-21 15:05:51 -08:00
Renato Zannon
598d8f93e4 fix(rustup): Extend now takes an IntoIterator 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
Renato Zannon
039e984f68 fix(rustup): Remove uses of the obsolete &a[] syntax 2015-02-21 15:05:50 -08:00
Renato Zannon
234fcdc3a2 fix(rustup): Fix signature of IntoCow 2015-02-21 15:05:50 -08:00
Renato Zannon
b0a72d80d0 feat(server): make AcceptorPool::accept() block and allow non'-static data
Change AcceptorPool to not spawn detached threads anymore. This,
together with the recent `Send` changes, allows the `work` closure to
close over non-`'static` data.

This doesn't change the high-level `Server` interface, because that
would make it's `listen` a blocking call (it's currently non-blocking)
- which would be a breaking change.
2015-02-21 15:05:50 -08:00
Renato Zannon
b47f936525 fix(rustup): update feature flags 2015-02-21 15:05:50 -08:00
Renato Zannon
fc2076cd53 fix(rustup): use module-level thread functions 2015-02-21 15:05:50 -08:00
Renato Zannon
f4a66b38cb fix(rustup): update lifetime bounds
Send no longer implies 'static; update needed lifetime bounds.
2015-02-21 15:05:50 -08:00
Sean McArthur
e8833c0c89 Merge pull request #325 from renato-zannon/macro-fix
fix(headers): use $crate when referring to hyper modules on macros
2015-02-19 13:35:02 -08:00
Renato Zannon
e246c3ace8 fix(headers): use $crate when referring to hyper modules on macros
This adds a $crate variable missed by de1be6726

Closes #323
2015-02-19 19:23:11 -02:00
Sean McArthur
bdb4d0e56e v0.1.13 2015-02-17 15:31:11 -08:00
Sean McArthur
e8529b3b98 Merge pull request #321 from pyfisch/refactorheaders
refactor(headers): Use macros for headers where possible
2015-02-17 08:46:03 -08:00
Pyfisch
de1be67262 refactor(headers): Use macros for headers where possible 2015-02-17 12:14:04 +01:00
Jonathan Reem
51bf1122dd Merge pull request #319 from pyfisch/partialordqualityitem
feat(headers): Implement PartialOrd for QualityItem
2015-02-15 14:30:43 -08:00
Pyfisch
2859d7ef4e feat(headers): Implement PartialOrd for QualityItem
PartialOrd is useful to sort Collections of QualityItems by quality.
So you can find the preferred match easier.

Closes #314
2015-02-15 18:01:03 +01:00
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