Skip to content

Commit 661587f

Browse files
committed
bump: v0.5.1
1 parent fab200a commit 661587f

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

Cargo.toml

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "form-data"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Fangdun Tsai <[email protected]>"]
55
description = "AsyncRead/AsyncWrite/Stream `multipart/form-data`"
66
homepage = "https://github.com/viz-rs/form-data"
@@ -21,7 +21,7 @@ include = [
2121
[features]
2222
default = ["async"]
2323

24-
async = ["futures-util"]
24+
async = ["futures-util/io"]
2525
sync = []
2626

2727
[dependencies]
@@ -33,24 +33,26 @@ memchr = "2.6"
3333
tracing = "0.1"
3434
thiserror = "1.0"
3535
serde = { version = "1.0", features = ["derive"] }
36-
futures-util = { version = "0.3", default-features = false, features = [
37-
"io",
38-
], optional = true }
36+
37+
[dependencies.futures-util]
38+
version = "0.3"
39+
default-features = false
40+
optional = true
3941

4042
[dev-dependencies]
4143
anyhow = "1.0"
42-
rand = "0.8"
4344
async-fs = "2.0"
44-
tempfile = "3.8"
45-
hyper = { version = "1.0", features = ["server", "http1"] }
46-
hyper-util = { version = "0.1", features = ["tokio"] }
4745
http-body = "1.0"
4846
http-body-util = "0.1"
47+
hyper = { version = "1.1", features = ["server", "http1"] }
48+
hyper-util = { version = "0.1.2", features = ["tokio"] }
49+
rand = "0.8"
50+
tempfile = "3.8"
51+
tiny_http = "0.12"
4952
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
5053
tokio-util = { version = "0.7", features = ["io"] }
5154
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
52-
warp = "0.3"
53-
tiny_http = "0.12"
55+
# warp = "0.3"
5456

5557
[[example]]
5658
name = "hyper"

src/async.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use futures_util::{
1111
io::{self, AsyncRead, AsyncWrite, AsyncWriteExt},
1212
stream::{Stream, TryStreamExt},
1313
};
14-
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
14+
use http::{
15+
header::{CONTENT_DISPOSITION, CONTENT_TYPE},
16+
HeaderValue,
17+
};
1518
use tracing::trace;
1619

1720
use crate::{
@@ -263,7 +266,10 @@ where
263266
// invalid content disposition
264267
let Some((name, filename)) = headers
265268
.remove(CONTENT_DISPOSITION)
266-
.and_then(|v| parse_content_disposition(v.as_bytes()).ok())
269+
.as_ref()
270+
.map(HeaderValue::as_bytes)
271+
.map(parse_content_disposition)
272+
.and_then(Result::ok)
267273
else {
268274
return Poll::Ready(Some(Err(Error::InvalidContentDisposition)));
269275
};

src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,21 @@
161161
#![allow(clippy::missing_errors_doc)]
162162

163163
mod error;
164+
pub use error::Error;
165+
164166
mod field;
165-
mod form;
166-
mod limits;
167-
mod state;
168-
mod utils;
167+
pub use field::Field;
169168

169+
mod form;
170170
pub use form::FormData;
171171

172-
pub use field::Field;
172+
mod limits;
173+
pub use limits::Limits;
173174

175+
mod state;
174176
pub use state::*;
175177

176-
pub use limits::Limits;
177-
178-
pub use error::Error;
178+
mod utils;
179179

180180
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
181181

src/state.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) enum Flag {
2020
Next,
2121
Eof,
2222
}
23+
2324
/// IO State
2425
pub struct State<T> {
2526
io: T,

src/utils.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ const NAME: &[u8; 4] = b"name";
1212
const FILE_NAME: &[u8; 8] = b"filename";
1313
const FORM_DATA: &[u8; 9] = b"form-data";
1414

15-
pub(crate) fn parse_content_type(header: Option<&http::HeaderValue>) -> Option<mime::Mime> {
15+
pub(crate) fn parse_content_type(header: Option<&HeaderValue>) -> Option<mime::Mime> {
1616
header
17-
.and_then(|val| val.to_str().ok())
18-
.and_then(|val| val.parse::<mime::Mime>().ok())
17+
.map(HeaderValue::to_str)
18+
.and_then(Result::ok)
19+
.map(str::parse)
20+
.and_then(Result::ok)
1921
}
2022

2123
pub(crate) fn parse_part_headers(bytes: &[u8]) -> Result<HeaderMap> {

0 commit comments

Comments
 (0)