1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![warn(clippy::all)]
pub mod codegen;
pub mod config;
pub mod request;
pub mod response;
pub mod thread_pool;
pub mod http;
pub mod http2;
#[cfg(test)]
mod tests {
#[test]
fn build_request() {
use crate::request::Request;
let request = Request::new(
b"Hello, World!".to_vec(),
vec!["Content-Type: text/plain".to_string()],
vec![
"GET".to_string(),
"/test".to_string(),
"HTTP/1.1".to_string(),
],
None,
);
assert_eq!(
*request.get_parsed_body().unwrap(),
"Hello, World!".to_string()
)
}
#[test]
fn build_response() {
use crate::response::Response;
let response = Response::new()
.body(b"1 2 3 test test...".to_vec())
.status_line("HTTP/1.1 200 OK");
assert_eq!(
String::from_utf8(response.body.unwrap()).unwrap(),
String::from("1 2 3 test test...")
);
}
}