1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-09-08 20:58:26 +00:00

update comments

This commit is contained in:
Nikolay Kim 2018-06-24 22:27:30 +06:00
parent c0cdc39ba9
commit d1b73e30e0
2 changed files with 16 additions and 7 deletions

View file

@ -413,7 +413,9 @@ where
pub fn content_disposition(&self) -> Option<ContentDisposition> {
// RFC 7578: 'Each part MUST contain a Content-Disposition header field
// 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()
} else {
None
@ -607,9 +609,10 @@ where
where
'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() {
let payload: &mut PayloadHelper<S> =
unsafe { &mut *self.payload.get() };
let payload: &mut PayloadHelper<S> = unsafe { &mut *self.payload.get() };
Some(payload)
} else {
None
@ -751,10 +754,16 @@ mod tests {
Ok(Async::Ready(Some(item))) => match item {
MultipartItem::Field(mut field) => {
{
use http::header::{DispositionType, DispositionParam};
use http::header::{DispositionParam, DispositionType};
let cd = field.content_disposition().unwrap();
assert_eq!(cd.disposition, DispositionType::Ext("form-data".into()));
assert_eq!(cd.parameters[0], DispositionParam::Ext("name".into(), "file".into()));
assert_eq!(
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().subtype(), mime::PLAIN);

View file

@ -146,7 +146,7 @@ impl Quoter {
}
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
Some(unsafe { Rc::new(String::from_utf8_unchecked(data)) })
} else {