Skip to content

Commit

Permalink
chore: remove bytes conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tejmagar committed Jun 28, 2024
1 parent dd71e50 commit 5b3cbaa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ impl HttpResponse {
}

pub fn location(mut self, url: &str) -> Box<Self> {
self.get_headers().set("Location", url.as_bytes());
self.get_headers().set("Location", url);
Box::new(self)
}

pub fn body<S: AsRef<str>>(mut self, data: S) -> Box<Self> {
let data = data.as_ref();

self.headers
.set("Content-Length", data.len().to_string().as_bytes());
.set("Content-Length", data.len().to_string());

if self.headers.value("Connection").is_none() {
if self.keep_alive {
self.headers.set("Connection", "keep-alive".as_bytes());
self.headers.set("Connection", "keep-alive");
} else {
self.headers.set("Connection", "close".as_bytes());
self.headers.set("Connection", "close");
}
}

Expand Down Expand Up @@ -163,11 +163,11 @@ impl JsonResponse {
if self.http_response.keep_alive {
self.http_response
.headers
.set("Connection", "keep-alive".as_bytes());
.set("Connection", "keep-alive");
} else {
self.http_response
.headers
.set("Connection", "close".as_bytes());
.set("Connection", "close");
}
}

Expand Down Expand Up @@ -223,7 +223,7 @@ impl ResponseStatus for JsonResponse {
fn with_status(status_code: u32, status_text: &str) -> Self {
let mut http_response = HttpResponse::with_status(status_code, status_text);
let headers = http_response.get_headers();
headers.set("Content-Type", b"application/json");
headers.set("Content-Type", "application/json");

Self { http_response }
}
Expand Down

0 comments on commit 5b3cbaa

Please sign in to comment.