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
47
48
49
50
51
52
use crate::http_signature::{HttpResponse, HttpStringList};
use std::collections::HashMap;
pub type Response = HttpResponse;
impl Response {
pub fn status_code(&mut self) -> i32 {
self.status_code.clone()
}
pub fn body(&mut self) -> Vec<u8> {
self.body.clone()
}
pub fn set_body(&mut self, body: String) -> &mut Self {
self.body = body.as_bytes().to_vec();
self
}
pub fn set_body_bytes(&mut self, bytes: Vec<u8>) -> &mut Self {
self.body = bytes;
self
}
pub fn headers(&self) -> &HashMap<String, HttpStringList> {
&self.headers
}
pub fn get_headers(&self, key: &String) -> Option<&HttpStringList> {
self.headers.get(key)
}
pub fn set_headers(&mut self, key: String, value: Vec<String>) {
self.headers.insert(key, HttpStringList { value });
}
}