mirror of
https://github.com/actix/actix-web.git
synced 2024-12-28 19:10:36 +00:00
move CD parsing to Content-Type parsing location
This commit is contained in:
parent
31a301c9a6
commit
a6e07c06b6
1 changed files with 15 additions and 13 deletions
|
@ -317,6 +317,13 @@ where
|
||||||
return Ok(Async::NotReady);
|
return Ok(Async::NotReady);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// content disposition
|
||||||
|
// RFC 7578: 'Each part MUST contain a Content-Disposition header field
|
||||||
|
// where the disposition type is "form-data".'
|
||||||
|
let cd = ContentDisposition::from_raw(
|
||||||
|
headers.get(::http::header::CONTENT_DISPOSITION)
|
||||||
|
).map_err(|_| MultipartError::ParseContentDisposition)?;
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
let mut mt = mime::APPLICATION_OCTET_STREAM;
|
let mut mt = mime::APPLICATION_OCTET_STREAM;
|
||||||
if let Some(content_type) = headers.get(header::CONTENT_TYPE) {
|
if let Some(content_type) = headers.get(header::CONTENT_TYPE) {
|
||||||
|
@ -360,9 +367,10 @@ where
|
||||||
Ok(Async::Ready(Some(MultipartItem::Field(Field::new(
|
Ok(Async::Ready(Some(MultipartItem::Field(Field::new(
|
||||||
safety.clone(),
|
safety.clone(),
|
||||||
headers,
|
headers,
|
||||||
|
cd,
|
||||||
mt,
|
mt,
|
||||||
field,
|
field,
|
||||||
)?))))
|
)))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,8 +385,8 @@ impl<S> Drop for InnerMultipart<S> {
|
||||||
|
|
||||||
/// A single field in a multipart stream
|
/// A single field in a multipart stream
|
||||||
pub struct Field<S> {
|
pub struct Field<S> {
|
||||||
ct: mime::Mime,
|
|
||||||
cd: ContentDisposition,
|
cd: ContentDisposition,
|
||||||
|
ct: mime::Mime,
|
||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
inner: Rc<RefCell<InnerField<S>>>,
|
inner: Rc<RefCell<InnerField<S>>>,
|
||||||
safety: Safety,
|
safety: Safety,
|
||||||
|
@ -389,22 +397,16 @@ where
|
||||||
S: Stream<Item = Bytes, Error = PayloadError>,
|
S: Stream<Item = Bytes, Error = PayloadError>,
|
||||||
{
|
{
|
||||||
fn new(
|
fn new(
|
||||||
safety: Safety, headers: HeaderMap, ct: mime::Mime,
|
safety: Safety, headers: HeaderMap, cd: ContentDisposition, ct: mime::Mime,
|
||||||
inner: Rc<RefCell<InnerField<S>>>,
|
inner: Rc<RefCell<InnerField<S>>>,
|
||||||
) -> Result<Self, MultipartError> {
|
) -> Self {
|
||||||
// RFC 7578: 'Each part MUST contain a Content-Disposition header field
|
Field {
|
||||||
// where the disposition type is "form-data".'
|
|
||||||
let cd = ContentDisposition::from_raw(
|
|
||||||
headers.get(::http::header::CONTENT_DISPOSITION)
|
|
||||||
).map_err(|_| MultipartError::ParseContentDisposition)?;
|
|
||||||
|
|
||||||
Ok(Field {
|
|
||||||
ct,
|
|
||||||
cd,
|
cd,
|
||||||
|
ct,
|
||||||
headers,
|
headers,
|
||||||
inner,
|
inner,
|
||||||
safety,
|
safety,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a map of headers
|
/// Get a map of headers
|
||||||
|
|
Loading…
Reference in a new issue