Commit Graph

908 Commits

Author SHA1 Message Date
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
Sean McArthur
1b869c4457 Merge pull request #647 from mlalic/issue-646
fix(http): Make sure not to lose the stream when CL is invalid
2015-09-04 16:33:48 -07: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
b833f67780 v0.6.12 2015-09-01 18:12:18 -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
Sean McArthur
8dbc38c75a Merge pull request #644 from erickt/serde
Minor serde micro-optimizations
2015-08-31 22:02:30 -07:00
Sean McArthur
ca67013493 Merge pull request #643 from erickt/master
fix "cargo test --features serde-serialization"
2015-08-31 22:02:20 -07:00
Erick Tryzelaar
63608c49c0 fix(examples): "cargo test --features serde-serialization" 2015-08-31 21:49:27 -07: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
5e0b952a37 v0.6.11 2015-08-27 15:50:52 -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
Sean McArthur
4f672fe744 Merge pull request #636 from mikedilger/connection
fix(headers): case insensitive values for Connection header
2015-08-27 15:47:04 -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
295e8e4708 v0.6.10 2015-08-19 14:57:00 -07:00
Sean McArthur
d32d35bbea fix(client): close connection when there is an Error 2015-08-19 14:37:47 -07:00
Sean McArthur
e305a2e9dc Merge pull request #632 from manuel-woelker/issue-629
feat(uri): implement fmt::Display for RequestUri (resolves #629)
2015-08-18 15:05:13 -07:00
Manuel Woelker
80931cf4c3 feat(uri): implement fmt::Display for RequestUri (resolves #629) 2015-08-18 22:28:23 +02:00
Sean McArthur
da2d29309a v0.6.9 2015-08-13 14:59:17 -07:00
Sean McArthur
0aaa351fe2 chore(cargo): update unicase version to 1.0 2015-08-13 14:58:07 -07:00
Sean McArthur
e1307b0d2f Merge pull request #631 from hyperium/server-request-ssl
add ssl() method to server Requests
2015-08-12 14:40:59 -07:00
Sean McArthur
0455663a98 fix(nightly): remove feature flag for duration 2015-08-12 14:39:37 -07:00
Sean McArthur
7909829f98 feat(server): add Request.ssl() to get underlying ssl stream
Closes #627
2015-08-12 14:13:14 -07:00
Sean McArthur
1a91835aba feat(net): impl downcast methods for NetworkStream (without + Send)
Closes #521
2015-08-12 14:12:16 -07:00
Sean McArthur
8791a7edf1 Merge pull request #625 from hyperium/no-content
improve detection of Client Response bodies
2015-08-05 17:19:35 -07:00
Sean McArthur
67c284a96a fix(client): improve keep-alive of bodyless Responses 2015-08-05 16:45:54 -07:00
Sean McArthur
31f117ea08 fix(client): improve HttpReader selection for client Responses
Closes #436
2015-08-05 16:42:48 -07:00
ealasu
af062ac954 feat(headers): Content-Range header 2015-08-05 11:33:38 -07:00
Sean McArthur
884fb1bbd9 v0.6.8 2015-08-03 12:07:41 -07:00
Sean McArthur
38d08e0213 v0.6.7 2015-08-03 12:06:15 -07:00
Sean McArthur
ee44d03458 docs(readme): improve server example to use res.send 2015-08-03 12:06:15 -07:00
Sean McArthur
5ca84f1666 chore(cargo): update mime dependency to 0.1 2015-08-03 12:06:15 -07:00
Sean McArthur
bfe948c39c Merge pull request #624 from mitsuhiko/feature/raw-fd
feat(raw-fd): implement FromRawFd/FromRawSocket
2015-08-02 00:11:27 -07:00
Armin Ronacher
664bde58d8 feat(raw-fd): implement FromRawFd/FromRawSocket
This allows HttpStream and HttpListener to be created from raw
sockets similar to their Tcp counterparts.  It also fixes up the
signature from i32 to RawFd for the AsRawFd method.
2015-08-01 23:11:26 +02:00
Sean McArthur
0a59d7377c Merge pull request #621 from hyperium/timeout
feat(net): add socket timeouts to Server and Client
2015-07-29 10:56:39 -07:00
Sean McArthur
8a7cac5aba Merge pull request #622 from muja/callback_con
feat(net): Implement NetworkConnector for closure to be more flexible
2015-07-28 16:04:52 -07:00
Danyel Bayraktar
abdd4c5d63 feat(net): Implement NetworkConnector for closure to be more flexible 2015-07-28 23:02:16 +02:00
Sean McArthur
7d1f154cb7 feat(net): add socket timeouts to Server and Client
While these methods are marked unstable in libstd, this is behind a
feature flag, `timeouts`. The Client and Server both have
`set_read_timeout` and `set_write_timeout` methods, that will affect all
connections with that entity.

BREAKING CHANGE: Any custom implementation of NetworkStream must now
  implement `set_read_timeout` and `set_write_timeout`, so those will
  break. Most users who only use the provided streams should work with
  no changes needed.

Closes #315
2015-07-27 09:57:59 -07:00
Jonathan Reem
421422b620 v.0.6.6 2015-07-25 11:09:59 -07:00
Jonathan Reem
7e9263386c Merge pull request #617 from pcwalton/serde-fix
Fix broken deserialization of headers.
2015-07-23 21:56:24 -07:00
Patrick Walton
f5f5e1cb2d fix(headers): fix broken deserialization of headers
Sorry about that!
2015-07-23 20:58:35 -07:00
Sean McArthur
aaf7995b43 v0.6.5 2015-07-23 13:43:42 -07:00
Sean McArthur
aa09034d2c Merge pull request #616 from hyperium/ssl-direct-streams
refactor(ssl): use openssl::DirectStreams
2015-07-23 13:30:52 -07:00