Commit Graph

761 Commits

Author SHA1 Message Date
Steven Fackler
8c7ef7fd93 feat(client): Implement Debug for Client
Protocol doesn't extend Debug so we have to leave that out of the
output unfortunately.
2016-02-15 14:43:50 -08:00
Sean McArthur
3a18e72be6 fix(buffer): fix incorrect resizing of BufReader
Closes #715
2016-01-04 15:00:37 -08:00
Mark Lee
f7d6ff67ee docs(headers): add docs for ExtendedValue members 2015-12-31 12:12:51 -08:00
Mark Lee
da0abe8988 feat(headers): allow ExtendedValue structs to be formatted and used as struct members 2015-12-31 12:12:51 -08:00
Corey Farwell
4c7f6f0c1e style(all): Address suggestions made by rust-clippy 2015-12-23 08:59:45 -08:00
Sean McArthur
69adbd1914 style(client): change instances of method::Method to Method 2015-12-19 13:59:33 -08:00
Steven Fackler
92ff50f2e5 fix(server): Flush 100-continue messages
Closes #704
2015-12-18 16:00:49 -08:00
Mark Lee
402fb76bb2 feat(headers): add extended parameter parser to the public API
Move the extended parameter parser from the Content-Disposition header
implementation into the common header parsing module. This allows crates that
use Hyper to parse RFC 5987-compliant header parameter values.
Add tests based on the examples given in the RFC.
2015-12-15 09:56:09 -08:00
Karl Hobley
1077440c4d test(server): Add test for GET request with body 2015-11-29 18:06:44 +00:00
Karl Hobley
0b05c5903e fix(server): Removed check for GET/HEAD request when parsing body
Fixes #698
2015-11-29 18:06:44 +00:00
Sean McArthur
fec6e3e873 feat(all): add socket timeouts
Methods added to `Client` and `Server` to control read and write
timeouts of the underlying socket.

Keep-Alive is re-enabled by default on the server, with a default
timeout of 5 seconds.

BREAKING CHANGE: This adds 2 required methods to the `NetworkStream`
  trait, `set_read_timeout` and `set_write_timeout`. Any local
  implementations will need to add them.
2015-11-24 10:58:58 -08:00
Mike Dilger
7623ecc264 feat(headers): Add Content-Disposition header
fixes #561
2015-11-24 08:51:06 +13:00
Sean McArthur
9c99e939a6 Merge pull request #693 from brycefisher/feat/access-control-allow-credentials
feat(headers): Add Access-Control-Allow-Credentials header
2015-11-22 08:47:46 -08:00
Bryce Fisher-Fleig
19348b892b feat(headers): Add Access-Control-Allow-Credentials header
There is only one acceptable value for this header, "true", so
there header struct is unit-like (no fields nor data inside). See
documentation and tests for more info. Case insensitive.

Closes #655
2015-11-22 00:53:16 -08:00
Sean McArthur
799698ca87 feat(headers): re-export CookiePair and CookieJar 2015-11-20 13:15:07 -08:00
Sean McArthur
81d42c964e chore(dependencies): update openssl to 0.7 and cookie to 0.2
Closes #686
2015-11-20 11:12:56 -08:00
Sean McArthur
d44ee5980f docs(quality_item): fix typo
Closes #634
2015-11-17 10:47:43 -08:00
Sean McArthur
6560e9edba Merge pull request #682 from hyperium/fix-win-x86-nounwind
test(windows): disable a panicking test for 32-bit msvc
2015-11-17 10:43:13 -08:00
Sean McArthur
8a5139e95f test(windows): disable a panicking test for 32-bit msvc 2015-11-16 14:01:57 -08:00
Dean4Devil
29fc868064 docs(server): Fixing two small typos 2015-11-12 09:44:54 +01:00
Markus Unterwaditzer
f783e9913b feat(headers): Add Access-Control-Expose-Headers
Fix #673
2015-11-02 22:09:49 +01:00
Kevin Butler
63c6762c15 fix(response): respond with a 500 if a handler panics 2015-10-29 23:51:59 +00:00
Pyfisch
4c756a9304 style(headers): use regular doc-comments inside macros
A bug (rust-lang/rust#23812) in rustc prevented the use of normal
comments inside macros but this has been fixed.
2015-10-27 19:19:05 +01:00
Jonathan Reem
fa0848d421 feat(server): Add hooks for HttpListener and HttpsListener to be started from existing listeners.
This allows Servers to be started on existing TcpListeners.
2015-10-18 19:01:44 -07:00
Huon Wilson
ff4a607057 refactor(client): make RequestBuilder non-generic
Improve the compile-time of downstream crates that use RequestBuilder,
by not forcing them to remonomorphise and recompile its non-generic
methods when they use it: with this change, they can just call the
precompiled versions in the `hyper` object file(s). The `send` method is
the major culprit here, since it is quite large and complicated.

For an extreme example,

    extern crate hyper;
    fn main() {
        hyper::Client::new().get("x").send().unwrap();
    }

takes ~4s to compile before this patch (i.e. generic RequestBuilder) and
~2s after. (The time spent interacting with LLVM goes from 2.2s to
0.3s.)

BREAKING CHANGE: `RequestBuilder<U>` should be replaced by `RequestBuilder`.
2015-10-14 15:23:55 +11:00
Huon Wilson
d2e9c94cf5 chore(nightly): remove ()'s and fix benchmarks for nightly
Also ensure that `cargo bench` runs successfully on travis; the old
`cargo bench ... || :` has the effect of ignoring any errors in it.
2015-10-14 15:04:15 +11:00
Sean McArthur
cdaa2547ed fix(server): use a timeout for Server keep-alive
Server keep-alive is now **off** by default. In order to turn it on, the
`keep_alive` method must be called on the `Server` object.

Closes #368
2015-10-09 15:02:05 -07:00
softprops
03827c3156 feat(client): add patch method to Client builder interface 2015-10-01 22:30:52 -04:00
Sean McArthur
54f084ad86 Merge pull request #656 from psdh/addPartialEqHead
feat(headers): add PartialEq impl for Headers struct
2015-09-21 08:09:51 -07:00
Prabhjyot Singh Sodhi
76cbf38423 feat(headers): add PartialEq impl for Headers struct
compare the raw representations of the headers for the lack of a better alternative
helpful when asserting HttpRequest/ HttpResponse in tests elsewhere
2015-09-17 10:40:10 +05:30
Sean McArthur
b872969880 fix(timeouts): remove rust #![feature] for socket timeouts 2015-09-16 14:30:12 -07:00
Peter Atashian
e0b9a11c9c test(windows): Ignore #[should_panic] tests on 32-bit msvc
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-09-10 00:09:14 -04:00
Sean McArthur
e9c62ccbab Merge pull request #648 from mlalic/h1-msg-keep-calm
[WIP] Add a stream state enum that makes it impossible to lose a stream
2015-09-09 10:50:37 -07:00
Mike Dilger
9b2998bddc fix(server): use EmptyWriter for status codes that have no body
Previously, hyper was defaulting to Chunked which adds a Transfer-Encoding
header, whenever there was no Content-Length header. RFC 7230 section 3.3.1
reads:

   ...
   A server MUST NOT send a Transfer-Encoding header field in any
   response with a status code of 1xx (Informational) or 204 (No
   Content). A server MUST NOT send a Transfer-Encoding header field in
   any 2xx (Successful) response to a CONNECT request
   ...

This commit fixes the cases of 1xx (Informational), 204 (No Content) by
using the EmptyWriter. It also uses EmptyWriter for 304 (NotModified) which
should not have a body.

It does NOT address the case of responses to CONNECT requests, or to HEAD
requests which do not send a body.  These cases cannot be determined using
the data available in the response, and are left for future work.
2015-09-08 09:36:35 +12:00
Marko Lalic
be4e718145 fix(http): Add a stream enum that makes it impossible to lose a stream
This removes a number of possible panics...
2015-09-07 11:05:41 +02:00
Marko Lalic
a36e44af7d fix(http): Make sure not to lose the stream when CL is invalid
When the Content-Length header is invalid, the Http11Message ends up
dropping the stream before returning the error. This causes a panic when
the `close_connection` method of the message is used later. This commit
fixes this by saving the stream onto the message instance before
returning the error. A regression test is also included.
2015-09-05 01:12:03 +02:00
Sean McArthur
32e09a0429 fix(client): EofReader by nature means the connection is closed 2015-09-02 09:26:46 -07:00
Sean McArthur
1ddb59418e Merge pull request #642 from mikedilger/thread_hooks
feat(server): Add Handler per-connection hooks
2015-09-01 18:10:18 -07:00
Sean McArthur
8b593691c6 Merge pull request #645 from hyperium/640-invalid-response
fix(client): be resilient to invalid response bodies
2015-09-01 18:09:26 -07:00
Sean McArthur
75c7117020 fix(client): be resilient to invalid response bodies
When an Http11Message knows that the previous response should not
have included a body per RFC7230, and fails to parse the following
response, the bytes are shuffled along, checking for the start of the
next response.

Closes #640
2015-09-01 16:58:51 -07:00
Mike Dilger
6b6182e8c4 feat(server): Add Handler per-connection hooks 2015-09-02 08:45:37 +12:00
Erick Tryzelaar
3a3c8b69a7 refactor(serde): Minor serde micro-optimizations 2015-08-31 21:49:05 -07:00
Sean McArthur
5c7195ab4a fix(http): fix several cases in HttpReader
- reading 0 bytes when SizedReader.remaining is more than 0 returns
"early eof" error
- reading 0 bytes when ChunkedReader.remaining is more than 0 returns
"early eof" error
- if SizedReader.remaining is less than buf.len(), the buf is sliced to
the remaining size
2015-08-31 19:30:52 -07:00
Sean McArthur
93e6d29a5e refactor(buffer): use vec macro in constructor, change trace logs 2015-08-31 19:30:41 -07:00
Sean McArthur
0af7abf62e refactor(mock): derive Debug for MockStream 2015-08-27 15:47:51 -07:00
Sean McArthur
ef15257b73 fix(client): fix panics when some errors occured inside HttpMessage
BREAKING CHANGE: This changes the signature of HttpWriter.end(),
  returning a `EndError` that is similar to std::io::IntoInnerError,
  allowing HttpMessage to retrieve the broken connections and not panic.

  The breaking change isn't exposed in any usage of the `Client` API,
  but for anyone using `HttpWriter` directly, since this was technically
  a public method, that change is breaking.
2015-08-27 15:47:51 -07:00
Mike Dilger
341f8eae6e fix(headers): case insensitive values for Connection header
Closes #635
2015-08-28 10:36:54 +12:00
Sean McArthur
44a4010537 docs(server): fix request.ssl() example to use SslStream<HttpStream>
Closes #633
2015-08-24 09:59:21 -07:00
Sean McArthur
d32d35bbea fix(client): close connection when there is an Error 2015-08-19 14:37:47 -07:00
Manuel Woelker
80931cf4c3 feat(uri): implement fmt::Display for RequestUri (resolves #629) 2015-08-18 22:28:23 +02:00