use crate::host::{Body, Header, handler};
pub struct Response {
header: Header,
body: Body,
}
static KIND_RES: i32 = 1;
impl Default for Response {
fn default() -> Self {
Self {
header: Header::kind(KIND_RES),
body: Body::kind(KIND_RES),
}
}
}
impl Response {
pub fn status(&self) -> i32 {
handler::status_code()
}
pub fn set_status(&self, code: i32) {
handler::set_status_code(code);
}
pub fn header(&self) -> &Header {
&self.header
}
pub fn body(&self) -> &Body {
&self.body
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_body() {
let r = Response::default();
let sut = r.body().read();
assert!(!sut.is_empty());
assert!(sut.starts_with(b"<html>"));
}
}