1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 00:44:26 +02:00

simplify AnyBody and BodySize (#2446)

This commit is contained in:
Rob Ede
2021-11-16 09:21:10 +00:00
committed by GitHub
parent e8a0e16863
commit 4df1cd78b7
17 changed files with 67 additions and 65 deletions

View File

@ -387,7 +387,7 @@ impl HttpResponseBuilder {
/// `HttpResponseBuilder` can not be used after this call.
#[inline]
pub fn finish(&mut self) -> HttpResponse {
self.body(AnyBody::Empty)
self.body(AnyBody::empty())
}
/// This method construct new `HttpResponseBuilder`
@ -475,7 +475,7 @@ mod tests {
fn test_content_type() {
let resp = HttpResponseBuilder::new(StatusCode::OK)
.content_type("text/plain")
.body(Body::Empty);
.body(Body::empty());
assert_eq!(resp.headers().get(CONTENT_TYPE).unwrap(), "text/plain")
}

View File

@ -87,13 +87,12 @@ impl HttpResponse {
#[cfg(test)]
mod tests {
use crate::dev::Body;
use crate::http::StatusCode;
use crate::HttpResponse;
#[test]
fn test_build() {
let resp = HttpResponse::Ok().body(Body::Empty);
let resp = HttpResponse::Ok().finish();
assert_eq!(resp.status(), StatusCode::OK);
}
}