Commit Graph

366 Commits

Author SHA1 Message Date
openharmony_ci 4b9586ecad !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 12db26ab0d README.OpenSource 中License信息整改
Signed-off-by: peizhe <zhaipeizhe@huawei.com>
2023-05-04 09:19:19 +08:00
openharmony_ci 8d4914eaa3 !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 dfb4e2377c Add GN Build Files and Custom Modifications
Signed-off-by: peizhe <472708703@qq.com>
2023-04-18 18:11:59 +08:00
Sean McArthur d46b71e764 v0.2.8 github.com/hyperium/http/refs/tags/v0.2.8 2022-06-06 15:06:17 -07:00
Sean McArthur 5b2719accc 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 fecfdfb92f 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 9f68ed7712 Update changelog to include msrv (#550) 2022-05-04 14:08:12 -07:00
Sean McArthur 95ad79b271 v0.2.7 2022-04-28 14:17:41 -05:00
Jed Denlea c1f309e0c3 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 bd30ce0b1c style: fix typo in code comment (#532) 2022-04-26 15:44:47 -07:00
Alex Touchet d82aa29813 readme: update some links (#548) 2022-04-26 13:35:13 -07:00
Jonas Platte f4cff03789 Add Extensions::extend (#546) 2022-04-26 10:51:25 -04:00
Alex Touchet 4fb67bcee1 Use SPDX license format (#547) 2022-04-25 18:28:11 -05:00
Jed Denlea d8b35db906 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 ec616ed84e Add test coverage for the StatusCode is_xxxxx() functions (#545) 2022-04-15 10:30:04 -07:00
Sean McArthur c28945c6c6 v0.2.6 2021-12-30 15:06:12 -08:00
Bruce Mitchener abe651273f 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 f25fbb579d 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 1129163281 remove obsolete comment
See 6003c8eef9
2021-11-16 08:20:55 -08:00
Tobias Bieniek 52b4d04d0d 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 ead020c94c v0.2.5 2021-09-21 10:37:20 -07:00
Ben Boeckel cc2f3ed7fc 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 d2fda209f1 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 58c6290bf9 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 e54da7175a 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 1179d6fa90 Fix typo in docs (#482) 2021-04-27 17:54:14 -07:00
Arnav Singh 73c723edb4 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 fc49fe39b7 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 f42f706ec5 Initial fuzzer set up. (#478) 2021-04-10 08:43:59 -07:00
Sean McArthur 97c35dd0c1 v0.2.4 2021-04-07 13:58:21 -07:00
Anthony Ramine 5c40eca8c0 Allow {, " and } in URI paths (#474) 2021-04-06 14:48:57 -07:00
Ilya Averyanov 5b90e389d7 Added benchmarks for parsing Method (#464) 2021-01-25 15:19:30 -08:00
Sean McArthur 7ba575fff2 v0.2.3 2021-01-08 10:43:22 -08:00
Sean McArthur 95c338e545 Upgrade to Bytes 1.0 2020-12-30 10:21:11 -08:00
David Kellum 01d6a590ed v0.2.2 2020-12-14 16:10:41 -08:00
David Kellum 722df557f9 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 8ffe094df1
    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 6c2b7897ef.

Closes #446
2020-12-11 10:26:23 -08:00
Abdullah Eryuzlu 43c6e84632 Return error if multiple brackets exist in the authority (#445)
Closes #435
2020-12-08 14:46:55 -08:00
Mats Kindahl 8be5a58f05 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 be05ed2418 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 b00473c3ec 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 975dbdd70a 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 4115fc1ea6 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 4f11af5bd2 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 d8996d237f 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 59733e146a 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 3ef1133c36 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 25c56744cd 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 dc865ff0fb 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 493b38fdc9 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