Commit Graph

313 Commits

Author SHA1 Message Date
Sean McArthur 228bef5e04 Remove unnecessary parentheses (#404) 2020-03-25 11:31:41 -07:00
Adam C. Foltzer 13a8a5734b Add extensions_ref() and extensions_mut() to req/resp builders (#403)
A similar capability already exists for many of the other `Parts` fields in these builders, and
is useful for the extensions map as well.
2020-03-25 11:19:15 -07:00
Matt Brubeck 3ee1b58295 HeaderMap: Store pos and hash as u16 (#386)
* HeaderMap: Store pos and hash as u16

HeaderMap currently truncates all hashes to 16 bits, and limits its
capacity to 32768 elements. The comments say this is done in order to
store positions and hashes as u16, to improve cache locality.  However,
they are currently stored as usize.  This patch changes the code to
match the comments.

This does not appear to cause any measurable improvement or regression
in speed in the HeaderMap benchmarks. However, it should at least reduce
the memory footprint of every Headermap.

* Fix overflow check for raw capacity.

The actual maximum capacity is 24578 (i.e. `32768 * 3/4`).

A higher number would cause the raw capacity (i.e. `capacity +
capacity/3` rounded to the next power of 2) to overflow `u16`.
2020-01-27 10:18:11 -08:00
Xidorn Quan 23a5f47c41 Remove unnecessary parentheses to fix warning (#388) 2020-01-27 10:09:35 -08:00
Sean McArthur 0644bfcbf4 Remove deprecated Error::description usage (#387) 2020-01-24 10:57:47 -08:00
Travis Cross d190cf73a4 Remove obsolete allow(warnings) attributes (#373)
We were for a time allowing warnings on two sections of code due to
continued use of `...` pattern syntax.  We had deferred the change to
`..=` syntax so as to support earlier Rust versions.

However, in commit `6059be7a99a264abf9afb8e6b8461413b972e892` we
changed over to `..=` syntax.  The `allow(warnings)` attributes and
the related comments are now obsolete, and we remove them in this
commit.
2019-12-10 13:17:00 -08:00
chip 9fa49b77a3 update suggested version in readme 2019-12-02 15:54:11 -08:00
Sean McArthur c2dabe50fa v0.2.0 2019-12-02 14:04:23 -08:00
Sean McArthur ed4dc57067 Add from_maybe_shared constructors
These constructors don't expose the internal `Bytes` type, but instead
will try to downcast the argument to prevent a copy. If the types don't
match up (a user provides an older version of `Bytes`), the value will
just be copied.

Adds:

- `HeaderValue::from_maybe_shared`
- `HeaderValue::from_maybe_shared_unchecked`
- `Uri::from_maybe_shared`
- `Authority::from_maybe_shared`
- `PathAndQuery::from_maybe_shared`
2019-12-02 13:12:38 -08:00
Sean McArthur 11efef0cb0 remove error type variants suffixed with Bytes
We reserved these extra error types with the goal of possibly returning
the source `Bytes` in the error type, but no one has since need this.
Since the dependency on `bytes` is being made private, it made sense to
remove these otherwise unused error types.

Removes:

- `InvalidUriBytes`
- `InvalidHeaderNameBytes`
- `InvalidHeaderValueBytes`
2019-12-02 13:12:38 -08:00
Sean McArthur bcccb669a4 Make all usage of Bytes private
Removes `from_shared` and `try_from` constructors for all types.
2019-12-02 13:12:38 -08:00
Erin Power 0421354979 Fix Method::is_idempotent 2019-12-02 11:15:56 -08:00
Sean McArthur 356bd8dd87 Change HeaderMap::drain API to match into_iter instead 2019-11-27 12:36:16 -08:00
Sean McArthur 48f838a77e Revert "Make ValueDrain eagerly collect its extra values"
This reverts commit 7742356863.

This patch was for 0.1.x, but is not necessary in 0.2.x due to an
upcoming API change for `Drain`.
2019-11-27 12:36:16 -08:00
Sean McArthur 833f231fa3 Upgrade to bytes 0.5 2019-11-26 12:08:28 -08:00
David Barsky a23d8edcfb Switch HttpTryFrom to TryFrom. 2019-11-26 12:08:28 -08:00
David Kellum 23fb5401fa update rand and quickcheck dev deps with usage changes 2019-11-26 12:08:28 -08:00
Sean McArthur 98e84c3515 Change request, response, and uri Builders to be by-value
Since the builders are only 1-time use anyways, it makes more sense to
enforce that through the type system, than to leave behind a panic bomb.

Most code that was just one chain should be un-affected.
2019-11-26 12:08:28 -08:00
Prasanna Loganathar 1a7d75adeb introduce TryFrom (#333) 2019-11-26 12:08:28 -08:00
David Barsky 8158916d23 Upgrade to 2018 Edition (#331)
* 2018 edition, babey!

* run `cargo fix --edition-idioms`

* yes, we do intend to drop the iterator, thanks rustc!

* cargo fmt

* aggressive min rustc version bump to fix travis

* 1.37 is not out, oops
2019-11-26 12:08:28 -08:00
Sean McArthur 697b83b65f allow deprecated uninitialized while min Rust is 1.30 2019-11-26 12:08:28 -08:00
Sean McArthur b36ea08c50 Change HeaderMap::entry to no longer return a Result
- Only types that implement `IntoHeaderName` can now be passed to
  `entry`, though they still are lazily cloned.
- Adds `HeaderMap::try_entry` that works as before, returning a `Result`
  if the key isn't a valid `HeaderName`.

This is a breaking change.
Closes #267
2019-11-26 12:08:28 -08:00
Sean McArthur 6059be7a99 Remove/rename deprecated APIs 2019-11-26 12:08:28 -08:00
Sean McArthur 55a0a0badb Use 'dyn' keyword with trait objects 2019-11-26 12:08:28 -08:00
Sean McArthur 20d04ade1c implement FusedIterator for all HeaderMap iterators (#318)
Increases minium Rust version to 1.26, when FusedIterator was
stabilized.
2019-11-26 12:08:28 -08:00
Kevin Choubacha 0cd6f5b118 Implement variant on version to require catch-all (#159) 2019-11-26 12:08:28 -08:00
Lucas Pardue d9a06a6e94 Add awareness of HTTP/3 (#294) 2019-11-26 12:08:28 -08:00
Sean McArthur fe5fefda4e start 0.2.x branch 2019-11-26 12:08:28 -08:00
Sean McArthur 64c5dd2644 v0.1.20 2019-11-26 10:26:34 -08:00
XAMPPRocky 1ee633e7a8 Refactor Method::is_idempotent for readability (#348) 2019-11-26 10:09:06 -08:00
Erick Tryzelaar fd7499ab0b Fix docs indentation (#347) 2019-11-26 10:08:19 -08:00
James 64064ac3eb Fix parsing of long host with no scheme (#351)
This change fixes an issue where an URI with no scheme, a host
part with a length greater than the max for a scheme, while only
consisting of valid characters for a scheme would fail to parse.

Rather than assuming the string being parsed is meant to contain
a scheme and returning an error if the max length for a scheme is
met, we instead extract the scheme part if it exists and validate
its length.

The trade-off is worse performance in the error case of a scheme
that is too long.
2019-11-26 10:07:37 -08:00
Sean McArthur 7742356863 Make ValueDrain eagerly collect its extra values 2019-11-26 10:03:09 -08:00
Sean McArthur e5ce34fe31 fix capacity overflows in HeaderMap::reserve 2019-11-25 16:29:21 -08:00
Sean McArthur c916e38eca Remove unused 'inner label 2019-11-25 11:36:28 -08:00
Sean McArthur 96abaae1fa Fix HeaderMap::drain double-free if drain iterator is forgotten 2019-11-25 11:35:03 -08:00
Sean McArthur 44f28adb5f v0.1.19 2019-10-15 11:46:00 -07:00
Sean McArthur 2c59983684 Improve Debug format of error types 2019-10-07 13:38:37 -07:00
Daniel Johnson ea4cc61a71 Allow % in IPv6 addresses to support zone identifiers. (#343)
https://tools.ietf.org/html/rfc6874 explains that %25 can be used to
indicate a "zone identifier", useful for IPv6 link-local addresses.
2019-10-07 13:04:51 -07:00
Sean McArthur b5ee552cff v0.1.18 2019-07-26 10:38:28 -07:00
Matthew Sherborne b633a7f2f6 Conditional compilation 2019-07-26 10:33:41 -07:00
Matthew Sherborne 21bff29f5b Added benchmarks for parsing header field names 2019-07-26 10:33:41 -07:00
Sean McArthur e755cc0fe8 Adjust HttpTryFrom for HeaderMap to be generic over the value type 2019-07-26 10:22:39 -07:00
Ophir LOJKINE 7ecbeb03f2 Implement HttpTryFrom<HashMap<String,String>> for HeaderMap (#326) 2019-07-25 10:22:13 -07:00
Guillaume Gomez 291a28912c Automatically test code examples in the README file (#314) 2019-07-15 14:50:56 -07:00
Sean McArthur 7f004434f3 Fix all deprecation warnings 2019-07-08 11:43:08 -07:00
Josh Leeb-du Toit 1cc157eaeb Export http::header::HeaderValue as http::HeaderValue (#222) 2019-06-26 13:11:05 -07:00
Sean McArthur 518b57ada5 v0.1.17 2019-04-05 09:58:09 -07:00
Kyle Huey ed3d506fbd Add headers/headers_mut accessors. (#293) 2019-04-05 09:44:36 -07:00
Sean McArthur fb68c44d09 Revert "Implementation of test and parsing for protocol relative uris (#300) (#301)" (#310)
This reverts commit 69f71dcf9f.
2019-04-02 17:48:04 -07:00