mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
update comments
This commit is contained in:
parent
c0cdc39ba9
commit
d1b73e30e0
@ -413,7 +413,9 @@ where
|
|||||||
pub fn content_disposition(&self) -> Option<ContentDisposition> {
|
pub fn content_disposition(&self) -> Option<ContentDisposition> {
|
||||||
// RFC 7578: 'Each part MUST contain a Content-Disposition header field
|
// RFC 7578: 'Each part MUST contain a Content-Disposition header field
|
||||||
// where the disposition type is "form-data".'
|
// where the disposition type is "form-data".'
|
||||||
if let Some(content_disposition) = self.headers.get(::http::header::CONTENT_DISPOSITION) {
|
if let Some(content_disposition) =
|
||||||
|
self.headers.get(::http::header::CONTENT_DISPOSITION)
|
||||||
|
{
|
||||||
ContentDisposition::from_raw(content_disposition).ok()
|
ContentDisposition::from_raw(content_disposition).ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -607,9 +609,10 @@ where
|
|||||||
where
|
where
|
||||||
'a: 'b,
|
'a: 'b,
|
||||||
{
|
{
|
||||||
|
// Unsafe: Invariant is inforced by Safety Safety is used as ref counter,
|
||||||
|
// only top most ref can have mutable access to payload.
|
||||||
if s.current() {
|
if s.current() {
|
||||||
let payload: &mut PayloadHelper<S> =
|
let payload: &mut PayloadHelper<S> = unsafe { &mut *self.payload.get() };
|
||||||
unsafe { &mut *self.payload.get() };
|
|
||||||
Some(payload)
|
Some(payload)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -751,10 +754,16 @@ mod tests {
|
|||||||
Ok(Async::Ready(Some(item))) => match item {
|
Ok(Async::Ready(Some(item))) => match item {
|
||||||
MultipartItem::Field(mut field) => {
|
MultipartItem::Field(mut field) => {
|
||||||
{
|
{
|
||||||
use http::header::{DispositionType, DispositionParam};
|
use http::header::{DispositionParam, DispositionType};
|
||||||
let cd = field.content_disposition().unwrap();
|
let cd = field.content_disposition().unwrap();
|
||||||
assert_eq!(cd.disposition, DispositionType::Ext("form-data".into()));
|
assert_eq!(
|
||||||
assert_eq!(cd.parameters[0], DispositionParam::Ext("name".into(), "file".into()));
|
cd.disposition,
|
||||||
|
DispositionType::Ext("form-data".into())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
cd.parameters[0],
|
||||||
|
DispositionParam::Ext("name".into(), "file".into())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
assert_eq!(field.content_type().type_(), mime::TEXT);
|
assert_eq!(field.content_type().type_(), mime::TEXT);
|
||||||
assert_eq!(field.content_type().subtype(), mime::PLAIN);
|
assert_eq!(field.content_type().subtype(), mime::PLAIN);
|
||||||
|
@ -146,7 +146,7 @@ impl Quoter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(data) = cloned {
|
if let Some(data) = cloned {
|
||||||
// we get data from http::Uri, which does utf-8 checks already
|
// Unsafe: we get data from http::Uri, which does utf-8 checks already
|
||||||
// this code only decodes valid pct encoded values
|
// this code only decodes valid pct encoded values
|
||||||
Some(unsafe { Rc::new(String::from_utf8_unchecked(data)) })
|
Some(unsafe { Rc::new(String::from_utf8_unchecked(data)) })
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user