Commit Graph

1534 Commits

Author SHA1 Message Date
Sean McArthur
8d6d9a21af refactor(header): remove some lifetime transmutes for keys in VecMap 2017-04-26 13:19:23 -07:00
Sean McArthur
38e60f7267 docs(header): update ContentType example to use ContentType::json() 2017-04-26 13:18:35 -07:00
Sean McArthur
a4644959b0 refactor(header): make Quality an opaque struct
This makes the `u16` in `Quality` private, since it only has a valid
range of 0-1000, and can't be enforced in public. The `q` function now
allows both `f32`s and `u16`s to construct a `Quality`.

BREAKING CHANGE: Any use of `Quality(num)` should change to `q(num)`.
2017-04-26 11:22:20 -07:00
Sean McArthur
316c6fad30 refactor(header): change HttpDate to opaque over SystemTime
This removes the need for someone to use the `time` crate to create a
date compatible with HTTP headers. It now works with the `SystemTime`
type from the standard library.

BREAKING CHANGE: `HttpDate` no longer has public fields. Convert between
  `HttpDate` and `SystemTime` as needed.
2017-04-25 14:30:49 -07:00
Sean McArthur
011f28cb18 fix(headers): remove erronous link-extensions from Link
They can be re-added later, removing now prevents that fix from being a
breaking change.

BREAKING CHANGE: The `link_extensions` methods of the `Link` header are
  removed until fixed.
2017-04-24 13:52:05 -07:00
Sean McArthur
21f547afb2 Merge branch 'http-connector-enforce-scheme' 2017-04-24 12:17:34 -07:00
Sean McArthur
6dd76a6839 perf(uri): inline Uri getters 2017-04-24 12:08:48 -07:00
Sean McArthur
1c34a05a85 feat(client): add HttpConnector.enforce_http
This will make the `HttpConnector` require the `scheme` to be `http`,
and return an error otherwise. This value is enabled by default, so any
requests to URLs that aren't of scheme `http` will now see an error
message stating the failure.

When constructing a connector that wraps an `HttpConnector`, this
enforcement can be disabled to allow connecting over TCP easily even
when the scheme is not `http`. To do, call
`connector.enforce_http(false)`.
2017-04-24 12:08:15 -07:00
Sean McArthur
6f02d43ae0 refactor(header): change Header::fmt_header to take a header::Formatter
The `header::Formatter` ensures that a formatted header is written to a
line, and allows for headers that require multiple lines. The only
header to specifically require this is `Set-Cookie`.

BREAKING CHANGE: The `fmt_header` method has changed to take a different
  formatter. In most cases, if your header also implements
  `fmt::Display`, you can just call `f.fmt_line(self)`.
2017-04-24 10:56:05 -07:00
Alexander Mielczarek
f1859dfd7a feat(headers): add TE header struct (#1150)
The `TE` header is used by a client to specify which
transfer encodings other than `chunked` it will accept.
It also specifies whether HTTP trailers are acceptable.
This commit also adds a `Trailers` variant to the
`hyper::header::shared::Encoding` enum.

Closes #1109 

BREAKING CHANGE: The `Encoding` enum has an additional
  variant, `Trailers`.
2017-04-24 10:21:06 -07:00
Alexey Zabelin
414859978b feat(headers): support Opaque origin headers (#1147)
Add support for Opaque origin header, serializing it to `null`.
https://html.spec.whatwg.org/multipage/browsers.html#concept-origin

Closes #1065

BREAKING CHANGE: `Origin.scheme` and `Origin.host` now return `Option`s,
  since the `Origin` could be `null`.
2017-04-24 10:05:56 -07:00
Sean McArthur
1cd8ea36f3 Merge pull request #1144 from Twey/master
client(feat): add an accessor for the request body
2017-04-20 09:31:30 -07:00
James Kay
4e26646aa7 feat(client): add an accessor for the request body
Allow users to access the body of the request.
Useful when one wants to modify the request based
on the data in the body, e.g. to add checksum headers.
2017-04-20 12:17:55 +01:00
Sean McArthur
bb7c9b9430 Merge pull request #1140 from birkenfeld/patch-1
docs(quality_item): fix typo
2017-04-18 12:41:28 -07:00
Georg Brandl
4c4da4c0e4 docs(quality_item): fix typo 2017-04-18 12:36:13 +02:00
Sean McArthur
736a342ea1 chore(travis): stop testing in non-existant doc directory 2017-04-17 10:42:22 -07:00
Sean McArthur
724d5e8669 chore(doc): remove unused doc folder 2017-04-17 10:29:28 -07:00
Sean McArthur
9605e860ff Merge pull request #1136 from hannesg/reduce_to_owned_in_origin
refactor(headers): use static "http"/"https" for scheme
2017-04-13 17:40:26 -07:00
hag
040c7d1949 refactor(headers): use static "http"/"https" for scheme
This change removes one common string allocation when parsing the origin
header.
2017-04-14 00:10:55 +02:00
Sean McArthur
574ded90dd Merge pull request #1135 from hyperium/server-keep-alive
fix(server): fix broken keep-alive in Server
2017-04-13 11:24:36 -07:00
Sean McArthur
0473d90a85 fix(server): fix broken keep-alive in Server
Closes #1134
2017-04-12 18:31:50 -07:00
Sean McArthur
f05a58a1b2 chore(travis): set minimum rust version 2017-04-10 15:09:54 -07:00
Sean McArthur
030393d099 Merge pull request #1121 from hannesg/allocator_friendly_header2
refactor(header): make Origin header more allocator friendly
2017-04-10 09:57:15 -07:00
Sean McArthur
52d3ff1c9b Merge pull request #1119 from hannesg/allocator_friendly_header
refactor(header): make some headers more allocator friendly
2017-04-10 09:55:13 -07:00
Sean McArthur
afd62971c3 Merge pull request #1123 from hyperium/body-concat
feat(chunk): implement Extend and IntoIterator for Chunk
2017-04-10 09:53:40 -07:00
hag
1b180dd61a refactor(header): make Originheader more allocator friendly
Change the internal representation of Origin to be more allocator
friendly. The internals of the Origin header are now private to allow
changing them in the future.

BREAKING CHANGES:
- Old code that accesses the Origin struct directly will stop working.
2017-04-10 11:11:33 +02:00
hag
c8d5bf5cc8 refactor(header): make some headers more allocator friendly
Change the internal implementation of some simple headers to make them
more allocator friendly. Also add a constructor method to allow changing
the implementation in the future again.

The headers are:

- Location
- Referrer
- Server
- UserAgent

This change was suggested in [#1104].

BREAKING CHANGES:
- Old code that creates the header structs directly will stop working.
- It's not possible to implement DerefMut for a Cow<'static,str>. Code
that needs to modify header after creation will stop working.
2017-04-10 10:48:16 +02:00
Sean McArthur
78512bdb18 feat(chunk): implement Extend and IntoIterator for Chunk
The real reason to provide these implementations is so that `concat` on
the `Body` can work to easily join all the chunks into 1.
2017-04-08 17:16:08 -07:00
Sean McArthur
5c1cfa2bce Merge pull request #1116 from hyperium/parse-till-blocked
fix(conn): always read till blocked when parsing
2017-04-05 16:30:33 -07:00
Sean McArthur
633b37df11 fix(conn): always read till blocked when parsing
Closes #1111
2017-04-05 15:45:20 -07:00
Sean McArthur
6e55fbe75d Merge pull request #1115 from hyperium/uri-fixes
Several Uri fixes
2017-04-05 15:19:00 -07:00
Sean McArthur
5d3499e036 fix(uri): fix Uri to origin_form when path is '*' 2017-04-05 14:36:39 -07:00
Sean McArthur
cb1927553e fix(uri): fix Uri to_origin_form to always include '/'
Closes #1112
2017-04-05 11:40:57 -07:00
Sean McArthur
1b49237e27 fix(uri): fix Uri.path() from containing '?' ever
Closes #1113
2017-04-05 09:57:12 -07:00
Sean McArthur
66ad619d6e Merge pull request #1110 from hyperium/flush
fix(conn): always flush io from poll_complete
2017-04-03 11:04:50 -07:00
Sean McArthur
997a64d770 fix(conn): always flush io from poll_complete
Closes #1108
2017-04-03 10:06:39 -07:00
Sean McArthur
d63b7de44f feat(client): Response.status() now returns a StatusCode
Previously, it would return `&StatusCode`. Returning a reference was
actually bigger than the enum itself, and prevented using `Into` on the
return result directly.

BREAKING CHANGE: If you were explicitly checking the status, such as
  with an equality comparison, you will need to use the value instead of a
  reference.
2017-03-31 15:13:55 -07:00
liamchristopher
47f3aa6247 feat(version): impl FromStr for HttpVersion 2017-03-30 14:34:46 -07:00
Sean McArthur
8dc06f211e Merge pull request #1105 from derekdreery/contributing_fix
docs(CONTRIBUTING): Fix markdown
2017-03-28 08:20:45 -07:00
Richard Dodd
1ee26443f4 docs(CONTRIBUTING): Fix markdown
Fix markdown in contributing so it displays correctly on github, and
also because of the irony.
2017-03-28 11:35:56 +01:00
Sean McArthur
3da720a99f Merge pull request #1103 from d12i/client-handle-getter
feat(client): add Client::handle
2017-03-26 17:58:46 -07:00
Daiki Mizukami
9101817b0f feat(client): add Client::handle 2017-03-27 08:06:07 +09:00
Sean McArthur
43cf9aefe8 Merge pull request #1101 from hyperium/remove-deprecated
refactor(header): remove deprecated Header to_string APIs
2017-03-21 18:22:12 -07:00
Sean McArthur
ec91bf418b refactor(header): remove deprecated Header to_string APIs
BREAKING CHANGE: This removes several deprecated methods for converting
  Headers into strings. Use more specialized methods instead.
2017-03-21 15:16:03 -07:00
Sean McArthur
4f69788f5d fix(client): get default port for https with Uri 2017-03-21 14:44:04 -07:00
Sean McArthur
3d8dddb066 Merge pull request #1100 from hyperium/un-url
feat(lib): remove extern Url type usage
2017-03-21 14:31:37 -07:00
Sean McArthur
4fb7e6ebc6 feat(lib): remove extern Url type usage
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
  `Client` API has had it replaced with `hyper::Uri`.

  This also means `Error::Uri` has changed types to
  `hyper::error::UriError`.

  The type `hyper::header::parsing::HTTP_VALUE` has been made private,
  as an implementation detail. The function `http_percent_encoding`
  should be used instead.
2017-03-21 11:03:57 -07:00
Sean McArthur
e81184e53c Merge pull request #1095 from mjkillough/header_view_raw
feat(headers): add HeaderView.raw()
2017-03-20 11:24:56 -07:00
Michael Killough
8143c33bad feat(headers): add HeaderView.raw()
Add HeaderView.raw() which behaves identically to Headers.get_raw().
2017-03-18 14:13:12 +07:00
Alex Crichton
8554904dc9 refactor(lib): convert usage of tokio_core::io to tokio_io
This commit updates to the most recent versions (released today) of the various
Tokio libraries in use. Namely the `tokio_core::io` module has now been
deprecated in favor of an external `tokio-io` crate. This commit pulls in that
crate and uses the `AsyncRead + AsyncWrite` abstraction instead of `Io` from
tokio-core.

BREAKING CHANGE: Any external types that were using that had implemented `Io` will need to 
  implement `AsyncRead + AsyncWrite` from tokio_io.
2017-03-17 17:31:44 -07:00