(fix) unwrap() => into_inner()
This commit is contained in:
@@ -187,7 +187,7 @@ impl Request<Streaming> {
|
|||||||
///
|
///
|
||||||
/// Consumes the Request.
|
/// Consumes the Request.
|
||||||
pub fn send(self) -> HttpResult<Response> {
|
pub fn send(self) -> HttpResult<Response> {
|
||||||
let raw = try!(self.body.end()).unwrap();
|
let raw = try!(self.body.end()).into_inner();
|
||||||
Response::new(raw)
|
Response::new(raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,8 +219,8 @@ mod tests {
|
|||||||
Get, Url::parse("http://example.dom").unwrap()
|
Get, Url::parse("http://example.dom").unwrap()
|
||||||
).unwrap();
|
).unwrap();
|
||||||
let req = req.start().unwrap();
|
let req = req.start().unwrap();
|
||||||
let stream = *req.body.end().unwrap().unwrap().downcast::<MockStream>().unwrap();
|
let stream = *req.body.end().unwrap().into_inner().downcast::<MockStream>().unwrap();
|
||||||
let bytes = stream.write.unwrap();
|
let bytes = stream.write.into_inner();
|
||||||
let s = from_utf8(bytes[]).unwrap();
|
let s = from_utf8(bytes[]).unwrap();
|
||||||
assert!(!s.contains("Content-Length:"));
|
assert!(!s.contains("Content-Length:"));
|
||||||
assert!(!s.contains("Transfer-Encoding:"));
|
assert!(!s.contains("Transfer-Encoding:"));
|
||||||
@@ -232,8 +232,8 @@ mod tests {
|
|||||||
Head, Url::parse("http://example.dom").unwrap()
|
Head, Url::parse("http://example.dom").unwrap()
|
||||||
).unwrap();
|
).unwrap();
|
||||||
let req = req.start().unwrap();
|
let req = req.start().unwrap();
|
||||||
let stream = *req.body.end().unwrap().unwrap().downcast::<MockStream>().unwrap();
|
let stream = *req.body.end().unwrap().into_inner().downcast::<MockStream>().unwrap();
|
||||||
let bytes = stream.write.unwrap();
|
let bytes = stream.write.into_inner();
|
||||||
let s = from_utf8(bytes[]).unwrap();
|
let s = from_utf8(bytes[]).unwrap();
|
||||||
assert!(!s.contains("Content-Length:"));
|
assert!(!s.contains("Content-Length:"));
|
||||||
assert!(!s.contains("Transfer-Encoding:"));
|
assert!(!s.contains("Transfer-Encoding:"));
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ impl Response {
|
|||||||
&self.status_raw
|
&self.status_raw
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unwraps the Request to return the NetworkStream underneath.
|
/// Consumes the Request to return the NetworkStream underneath.
|
||||||
pub fn unwrap(self) -> Box<NetworkStream + Send> {
|
pub fn into_inner(self) -> Box<NetworkStream + Send> {
|
||||||
self.body.unwrap().unwrap()
|
self.body.unwrap().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ mod tests {
|
|||||||
status_raw: RawStatus(200, Slice("OK"))
|
status_raw: RawStatus(200, Slice("OK"))
|
||||||
};
|
};
|
||||||
|
|
||||||
let b = res.unwrap().downcast::<MockStream>().unwrap();
|
let b = res.into_inner().downcast::<MockStream>().unwrap();
|
||||||
assert_eq!(b, box MockStream::new());
|
assert_eq!(b, box MockStream::new());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -748,7 +748,7 @@ mod tests {
|
|||||||
let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new());
|
let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new());
|
||||||
w.write(b"foo bar").unwrap();
|
w.write(b"foo bar").unwrap();
|
||||||
w.write(b"baz quux herp").unwrap();
|
w.write(b"baz quux herp").unwrap();
|
||||||
let buf = w.end().unwrap().unwrap();
|
let buf = w.end().unwrap().into_inner();
|
||||||
let s = from_utf8(buf.as_slice()).unwrap();
|
let s = from_utf8(buf.as_slice()).unwrap();
|
||||||
assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n");
|
assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n");
|
||||||
}
|
}
|
||||||
@@ -760,7 +760,7 @@ mod tests {
|
|||||||
w.write(b"foo bar").unwrap();
|
w.write(b"foo bar").unwrap();
|
||||||
assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1))));
|
assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1))));
|
||||||
|
|
||||||
let buf = w.end().unwrap().unwrap();
|
let buf = w.end().unwrap().into_inner();
|
||||||
let s = from_utf8(buf.as_slice()).unwrap();
|
let s = from_utf8(buf.as_slice()).unwrap();
|
||||||
assert_eq!(s, "foo barb");
|
assert_eq!(s, "foo barb");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user