Commit Graph

1652 Commits

Author SHA1 Message Date
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
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
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
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
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
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
3af8b687d4 fix(rustup): switch to unstable features 2015-01-31 12:15:44 -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
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
2d55a22e73 feat(status): add is_<status_class>() methods to StatusCodes 2015-01-27 18:07:23 -08:00
Sean McArthur
b002b6c3f0 fix(log): update to new logging levels 2015-01-27 09:08:01 -08:00
Jonathan Reem
1ebbdedd13 chore(warnings): Allow direct recursion for type enforcement. 2015-01-27 09:08:01 -08:00
Kevin Butler
c592b71d64 refactor(server): Add explicit lifetime annotations for Handler trait 2015-01-27 00:23:24 +00:00
Sean McArthur
e5417b834b Merge pull request #271 from pyfisch/cookie
refactor(headers): Rename `Cookies` header to `Cookie`
2015-01-26 10:35:34 -08:00
Pyfisch
92f43cf873 refactor(headers): Rename Cookies header to Cookie
`Cookie` is the actual name of the header and since all other header structs
use the exact camel-cased version of their name using a different name here
is very inconvienient and confusing. You will encounter weird errors if you
try to use `Cookie` as the header. For this reason rename `Cookies` as
discussed on IRC with @seanmonstar and @reem and use `CookiePair` for real
cookies.

BREAKING CHANGE: Change header `Cookie` to `Cookie`
2015-01-26 17:10:36 +01:00
Pyfisch
767c95d2b9 feat(headers): Add Pragma header field
Add the HTTP/1.0 `Pragma` header field used to prevent older Caches, that
do not understand the `Cache-Control` header field from caching the ressource.

Closes #237
2015-01-24 15:09:59 +01:00
Jason N
e06e7d9a7e fix(headers): make ConnectionHeader unicase
Make ConnectionHeader case-insensitive since HTTP headers are
case-insensitive
2015-01-24 16:09:20 +11:00
Jason N
65c7018046 fix(headers): make Protocol search websocket unicase
RFC6455 requires the Upgrade Protocol to search case-insensitively for
"websocket"
Other protocol values may be case-sensitive, however, so ProtocolExt is
still case-sensitive
2015-01-24 16:08:09 +11:00
Sean McArthur
9e3c94d764 fix(rustup): update to newest fmt trait names and slice syntax 2015-01-23 14:17:19 -08:00
Sean McArthur
8215889eda refactor(headers): remove marker from header_name method
It is no longer required, as we can use `<H as Header>::header_name()`.

BREAKING CHANGE: Implementations of Header will need to adjust the
    header_name method. It no longer takes any arguments.
2015-01-22 15:20:38 -08:00
Jason N
e43c35c1ca fix(headers): make Schemes, Basic, Protocol public
Expose Authorization header Scheme trait and Basic authorization
Expose the Upgrade header Protocol
2015-01-22 14:26:51 +11:00
ProtectedMode
115f56adf9 refactor(headers): make CacheDirective public 2015-01-21 21:43:38 +00:00
Alex Whitney
dd2534a686 fix(imports): Update TypeID import location to "any" 2015-01-21 18:54:57 +00:00
Jonathan Reem
b512e23a3e Merge pull request #260 from pyfisch/rheaders
refactor(headers): export all headers and utils directly under header
2015-01-21 16:45:03 +01:00
Jonathan Reem
cd1a65633f Merge pull request #261 from reem/request-deconstruct
server(feat): add a deconstruct method to Request.
2015-01-21 01:22:38 +01:00
Jonathan Reem
1014855fae feat(server): add a deconstruct method to Request. 2015-01-21 01:17:57 +01:00
Pyfisch
8d0e5bc302 refactor(headers): export all headers and utils directly under header
Currently headers are exported at many places. For example you can access
`Transfer-Encoding` header at `header`, `header::common` and
`header::common::transfer_encoding`. Per discussion on IRC with
@seanmonstar and @reem, all contents of headers will be exposed at `header`
directly. Parsing utilities will be exposed at `header::parsing`. Header
macros can now be used from other crates.

This breaks much code using headers. It should use everything it needs
directly from `header::`, encodings are exposed at `header::Encoding::`,
connection options are exposed at `header::ConnectionOption`.
2015-01-20 13:04:42 +01:00
Sean McArthur
7a5813b4b2 Merge pull request #235 from kstep/referer-header
Add `Referer` header definition
2015-01-19 15:45:18 -08:00
Piotr Zolnierek
54238b28e4 fix(server): Increase MAX_HEADER_FIELD_LENGTH to 4k
In order to be able to handle larger headers than 1k, for example
header containing tracking cookies etc.

references:
- http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers
- http://stackoverflow.com/questions/686217/maximum-on-http-header-values
2015-01-19 19:55:01 +01:00
Pyfisch
dfa5e69d7c refactor(headers): add header macros and add two example uses
Add `impl_header!` and `impl_list_header!` macros. Rewrite `Accept-Encoding`
and `Server` header implementations to use the new macros.
2015-01-15 19:26:33 +01:00
Manish Goregaokar
bca9a53c66 feat(net): Move SSL verification to unboxed closures 2015-01-15 22:23:13 +05:30
Manish Goregaokar
af5778510d feat(net): Allow more generic SSL verification (fixes #244) 2015-01-14 19:29:48 +05:30
Sean McArthur
aa26665367 fix(header): fix fmt_header outputs of several headers
Closes #246
2015-01-13 10:42:01 -08:00
Sean McArthur
cfebdabc1a Merge pull request #241 from retep998/master
Don't use Show to write UserAgent header
2015-01-12 09:05:55 -08:00
Peter Atashian
c8e334aaeb fix(headers): don't use Show to write UserAgent header
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-01-11 23:36:17 -05:00
Kelvin Ly
c6eef68124 feat(server,net): Add TLS/SSL support serverside
Implements the missing enum cases in Http* and adds a new
method to the default Server implementation to take advantage
of the new TLS support

Closes #1
2015-01-11 23:33:11 -05:00
Sean McArthur
95f178653c Merge pull request #236 from hyperium/rustup
Rust up for nightly
2015-01-10 21:36:04 -08:00
Sean McArthur
f7124bb8e2 rustup: sweeping fixes for all the changes in 1.0-alpha
- Some switches to u64 instead of usize
- For now, allow(unstable)
- use associated types for all the Network stuff
2015-01-10 21:29:27 -08:00
Konstantin Stepanov
df857aa3f8 add referer header definition 2015-01-11 02:19:29 +03:00
Konstantin Stepanov
d60e54dc55 fixes invalid format of mime types
See also mime.rs/#14
2015-01-10 19:27:10 +03:00
cyderize
d9c657da73 Make status::StatusCode_0 pass
Needed to allow unstable.

Also, why do we depend on typeable? Removed from Cargo.toml
2015-01-10 19:36:51 +11:00
cyderize
cc7fa15b04 Continue updating for latest rust
Fixed tests, however cannot link bench tests for some reason
2015-01-10 19:15:46 +11:00
cyderize
122e94c8a6 Update for latest rust
Tracks rust nightly.

7 tests fail -- still finding source
2015-01-10 18:37:10 +11:00
Robin Gloster
da0597510a macro syntax changes 2015-01-07 21:30:03 +01:00
Sean McArthur
b45912dd16 Merge pull request #225 from pyfisch/accesscontrol
Added AccessControl* family of headers.
2015-01-06 17:31:47 -08:00
Marko Lalic
f327a7e737 Add regression tests for chunked request parsing
The tests assert that requests with a `Transfer-Encoding: chunked`
are correctly parsed both when the chunks are valid, as well as
invalid.
2015-01-06 22:15:18 +01:00
Marko Lalic
2357995cc9 Add regression tests for chunked response parsing
The tests assert that `Transport-Encoding: chunked` responses are
correctly handled both when the chunk sizes are valid, as well as
invalid.
2015-01-06 22:15:18 +01:00
Pyfisch
c228a5506a Worked on Access-Control-* header family. 2015-01-06 22:04:35 +01:00