366 Commits

Author SHA1 Message Date
openharmony_ci cf4b7faf68 !2 README.OpenSource 中License信息整改
Merge pull request !2 from peizhe/master
OpenHarmony-v4.0-Beta1 OpenHarmony-v4.0-Beta2
2023-05-05 02:26:13 +00:00
peizhe 1755bb8347 README.OpenSource 中License信息整改
Signed-off-by: peizhe <zhaipeizhe@huawei.com>
2023-05-04 09:19:19 +08:00
openharmony_ci 698a0483e7 !1 [http]Add GN Build Files and Custom Modifications to Rust Third-party Libraries
Merge pull request !1 from peizhe/master
2023-04-19 01:28:23 +00:00
peizhe 30e96d8a04 Add GN Build Files and Custom Modifications
Signed-off-by: peizhe <472708703@qq.com>
2023-04-18 18:11:59 +08:00
Sean McArthur 884c6a2a85 v0.2.8 github.com/hyperium/http/refs/tags/v0.2.8 2022-06-06 15:06:17 -07:00
Sean McArthur 45ff933127 Convert header::name to use MaybeUninit (#555)
Co-authored-by: Steven Bosnick <sbosnick@sympatico.ca>
2022-06-06 14:08:18 -07:00
Nicholas Nethercote fa0c07e303 Fix doc(hidden) errors. (#553)
Compiling with `cargo 1.63.0-nightly (3f052d8ee 2022-05-12)` I get lots
of errors like this:
```
error: `#[doc(hidden)]` is ignored on trait impl items
    --> src/header/map.rs:3296:9
     |
3296 |         #[doc(hidden)]
     |         ^^^^^^^^^^^^^^ help: remove this attribute
     |
note: the lint level is defined here
    --> src/lib.rs:161:9
     |
161  | #![deny(warnings, missing_docs, missing_debug_implementations)]
     |         ^^^^^^^^
     = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]`
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
     = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
```
This commit removes all these unnecessary attributes so that `http` compiles
again with Nightly.
2022-05-19 15:29:05 -07:00
Lucio Franco b6affa427b Update changelog to include msrv (#550) 2022-05-04 14:08:12 -07:00
Sean McArthur 7ebefad283 v0.2.7 2022-04-28 14:17:41 -05:00
Jed Denlea 5894f7d0f2 From impls of PathAndQuery and Authority for Uri (#538)
* From impls of PathAndQuery and Authority for Uri

A Uri may logically hold only an Authority or only a PathAndQuery.
Should an application want to make such Uris, it would be easier to
safely create them by first making just an Authority or just a
PathAndQuery, then cheaply convert them directly into a Uri.

* Fix Uri docs

The doc comments for `impl From<Uri> for Parts` actually described
`Uri::from_parts`.
2022-04-28 07:16:56 -05:00
graves501 f16fad8f74 style: fix typo in code comment (#532) 2022-04-26 15:44:47 -07:00
Alex Touchet ae8e15046d readme: update some links (#548) 2022-04-26 13:35:13 -07:00
Jonas Platte 316da9e1fa Add Extensions::extend (#546) 2022-04-26 10:51:25 -04:00
Alex Touchet be57e6a30d Use SPDX license format (#547) 2022-04-25 18:28:11 -05:00
Jed Denlea 49d19ff8a4 Make HeaderName::from_static const (#499)
... plus some clean-up.

It was only after I came up with the scheme using
`const fn from_bytes(&[u8]) -> Option<StandardHeader>`
that I noticed the debug+wasm32-wasi version of `parse_hdr`, which had
something very similar.

While cleaning up that function, I realized it still would still panic
if an attempted name was too long, which had been fixed for all other
targets and profiles in #433.  Then, I thought it would be worth seeing
if the use of `eq!` in the primary version of `parse_hdr` still made any
difference.

And, it would not appear so. At least not on x86_64, nor wasm32-wasi run
via wasmtime.  I've run the benchmarks a number of times now, and it
seems the only significant performance change anywhere is actually that
of `HeaderName::from_static` itself, which now seems to run in about 2/3
the time on average.

Unfortunately, `const fn` still cannot `panic!`, but I've followed the
lead from `HeaderValue::from_static`.  While that version required 1.46,
this new function requires 1.49.  That is almost 8 months old, so
hopefully this isn't too controversial!
2022-04-16 08:40:20 -07:00
Ingmar van Dijk e3cf31d8b3 Add test coverage for the StatusCode is_xxxxx() functions (#545) 2022-04-15 10:30:04 -07:00
Sean McArthur 945ffbfd3e v0.2.6 2021-12-30 15:06:12 -08:00
Bruce Mitchener d2bfc27f87 deps: Update to itoa 1.
In itoa 1, the interface has been slimmed down and the fmt method
is no longer present, so expand to the code that was there previously.
2021-12-14 10:47:23 -08:00
Tobias Bieniek 3a8fbdcd84 Cargo: Add rust-version field
see https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
2021-11-16 09:21:23 -08:00
Tshepang Lekhonkhobe 3eb5e80870 remove obsolete comment
See 6059be7a99
2021-11-16 08:20:55 -08:00
Tobias Bieniek 6333e3971b README: Remove obsolete extern crate http instructions
This crate declares `edition = 2018`, in which these `extern crate` instructions are no longer necessary, so it should be safe to remove them from the README file.
2021-11-11 15:45:30 -08:00
Sean McArthur d9ba5572bd v0.2.5 2021-09-21 10:37:20 -07:00
Ben Boeckel 0c7125fb96 extensions: add methods to detect the presence of extensions (#497)
This is useful to know that a `Builder` instance cannot be duplicated
faithfully since the extensions cannot be cloned into a new instance.
2021-08-10 12:43:46 -07:00
Ben Boeckel e59f5add8c request: add Builder::version_ref to query the version in use (#495)
This is needed to manually clone `Builder` instances reliably.
2021-08-10 12:21:55 -07:00
Dave Schuyler 5c5c46ce5e Minor changes to var names in examples (#493)
Using "res" for Response rather than "req".
2021-07-30 14:54:11 -07:00
Jerome Gravel-Niquet ce901ad9ea HeaderValue::from_static can be const (#481)
* HeaderValue::from_static can be const

* bump MSRV to 1.46.0 for const loop
2021-06-09 11:31:55 -07:00
walfie 53826c9ee9 Fix typo in docs (#482) 2021-04-27 17:54:14 -07:00
Arnav Singh 6a91d66523 Add missing TryFrom<String> and TryFrom<Vec<u8>> impls. (#477)
Also fix PathAndQuery's TryFrom<String> impl to not copy the bytes into
a new Bytes.
2021-04-21 06:54:31 -07:00
Stephen M. Coakley f7195c92d7 Add TryFrom implementations for owned types for HeaderName (#479)
`HeaderValue` implements `TryFrom` over both reference and owned types, but `HeaderName` does not. This seemed like an accidental omission to me rather than something intentionally absent. Including this conversion slightly increases ergonomics by allowing you to create a `HeaderMap` from a `HashMap<String, String>` and in similar other constraints.

See also https://github.com/sagebind/isahc/issues/314.
2021-04-16 15:04:34 -07:00
DavidKorczynski 04776e9522 Initial fuzzer set up. (#478) 2021-04-10 08:43:59 -07:00
Sean McArthur 8698e76a0e v0.2.4 2021-04-07 13:58:21 -07:00
Anthony Ramine 35fa69a9f1 Allow {, " and } in URI paths (#474) 2021-04-06 14:48:57 -07:00
Ilya Averyanov 54cf8785ab Added benchmarks for parsing Method (#464) 2021-01-25 15:19:30 -08:00
Sean McArthur 8d373de151 v0.2.3 2021-01-08 10:43:22 -08:00
Sean McArthur 4f8c77089c Upgrade to Bytes 1.0 2020-12-30 10:21:11 -08:00
David Kellum 1dcd1ea866 v0.2.2 2020-12-14 16:10:41 -08:00
David Kellum 200ebdb798 Fixes panic for remove_entry and remove_entry_mult (#449)
* add test case for OccupiedEntry::remove_entry_mult

This is just a self contained test case, currently reproducing the
panic of #446.

* expand test cases for remove_entry_mult

* add multiple remove_entry_mult call tests to show more issues

* test repeated HeaderMap::remove for comparison

* tests showing similar problem with remove_entry on extra values

* fix remove_entry by moving remove_found after remove_all_extra_values

* fix remove_entry_mult by eager collection of extras before remove_found

In order to remove extra values prior to remove_found, we must collect
them eagerly. Eager collection is based on:

    commit 7742356863
    Author:     Sean McArthur <sean@seanmonstar.com>
    AuthorDate: Mon Nov 25 17:34:30 2019 -0800
    Commit:     Sean McArthur <sean@seanmonstar.com>
    CommitDate: Tue Nov 26 10:03:09 2019 -0800

	Make ValueDrain eagerly collect its extra values

...which was reverted in 48f838a77e.

Closes #446
2020-12-11 10:26:23 -08:00
Abdullah Eryuzlu b7fb530866 Return error if multiple brackets exist in the authority (#445)
Closes #435
2020-12-08 14:46:55 -08:00
Mats Kindahl eed07d5c0d Add String and &String convert for PathAndQuery (#450)
When building a URI, it is not possible to provide neither String nor
&String, which is useful when adding a path_and_query from a string
built using format!.

This commit adds implementation of From<String> and From<&String> for
PathAndQuery.
2020-12-08 12:34:27 -08:00
David Kellum d4f2c076ca Allow StatusCode to support 600-999 range
Additionally, reduces the size of the static memory included, and reduces some of the complicated macro usage resulting in faster compiles!

Co-authored-by: quininer <quininer@live.com>
Co-authored-by: David Kellum <dek-oss@gravitext.com>
2020-12-08 12:26:09 -08:00
Adam C. Foltzer 58f6523f49 Return an error rather than panicking when HeaderName is too long (#433)
Fixes #432.

This eliminates an undocumented panic from the `HeaderName` creation functions, returning instead an
`InvalidHeaderName` when the name length exceeds `MAX_HEADER_NAME_LEN`.

I considered making `InvalidHeaderName` a richer error type, but since it was already used for
another type of length error (rejecting zero-length names) I figured it was okay to reuse.

I also redefined `MAX_HEADER_NAME_LEN` slightly, so that it is equal to the largest allowed header
length, rather than one past that value. This was motivated by discovering a bug in my comparison
logic when I went to write the new test exercising the wrong-length error conditions.
2020-08-03 16:28:18 -07:00
Steven Bosnick 2f56485974 Audit the use of unsafe in byte_str.rs (#408)
Add comments describing the invariant that makes the one use of unsafe
sound.
2020-06-24 13:11:02 -07:00
Patrick Lühne 5d08f81a98 Clarify meaning of sensitive header values (#427)
While the documentation mentions that header values can be marked as
sensitive in order to inform outside components that these header values
may require special treatment, it was unclear to me whether doing that
affects the behavior of this crate.

This adds a short note to the documentation to clarify that the main
purpose of the sensitivity flag is to make components building on this
crate to be aware of sensitive data, such that it can be treated with
special care for security purposes.
2020-06-01 10:38:52 -07:00
Steven Bosnick 9a781498f0 Fix the build status badge in README.md (#426)
This change makes the alt tag for the badge image closer to what is
shown in the immage itself (both are will show the name of the workflow:
CI) and makes the badge a link to the summary page for the CI workflow
in the GitHub Actions web interface.
2020-05-24 16:39:48 -07:00
Steven Bosnick 9019d4c09d Fix the "Build Status" indicator in README.md (#425)
The "Build Status" markup badge had not been updated to refect the
change of CI systems from TravisCI to GitHub Actions.
2020-05-24 08:57:58 -07:00
Steven Bosnick 9cceef63f0 Audit use of unsafe in uri/authority.rs (#414)
* Add unit test for rejecting invalid UTF-8

* Add Authority::from_static() test

* Refactor uri::Authority

Extract the common code from three ways of creating an Authority into a
private create_authority() function.

* Add comments to explain the safety of Authority

The comments describe the preconditions and postconditions that together
ensure that the one use of 'unsafe' in uri/authority.rs is sound.

* Fix typo
2020-05-14 07:58:07 -07:00
Steven Bosnick 6a7d85d7b6 Add comments to describe safety of Scheme
The comments describe the postcondition on parse_exact() that makes the
one use of "unsafe" in Scheme::try_from(&'a [u8]) sound.
2020-05-07 14:59:30 -07:00
Steven Bosnick e3ffd3a4e3 Add tests for directly parsing a Scheme
The tests include an [u8] that is invalid UTF-8.
2020-05-07 14:59:30 -07:00
Steven Bosnick 689fd17504 Document the invariants that make Method safe
The internal InlineExtension and AllocatedExtension types have
invariants that ensure that the two uses of "unsafe" in the "extension"
submodule of "method" are safe. This documents those invariants for
future reference.
2020-05-07 14:57:58 -07:00
Steven Bosnick d37b977fdb Refactor Method internals
Extract the inner types for ExtensionAllocated and ExtensionInline into
a separate extension module that has the supporting functions as
non-public elements.

This refactoring moves the use of "unsafe" into this new "extension"
module and provides a safe wrappers around the two uses of "unsafe".
2020-05-07 14:57:58 -07:00