wdg_request/
lib.rs

1extern crate string_repr;
2extern crate wdg_uri;
3
4pub mod header;
5pub mod method;
6
7use header::Header;
8use method::Method;
9//use std::error::Error;
10//use string_repr::StringRepr;
11use wdg_uri::URI;
12//
13//pub enum RequestError {
14//    URIDoesNotContainAuthority,
15//}
16//
17pub struct Request<'a> {
18    method: Method,
19    uri: URI<'a>,
20    headers: Vec<Header<'a>>,
21    data: Option<Vec<u8>>,
22}
23
24//impl Request {
25//    pub fn new(method: Method, uri: URI) -> Result<Request, RequestError> {
26//        let mut headers = Vec::<header>::new();
27////        match &uri.authority {
28////            Some(authority) => {
29////                let header = header::new("Host".into(), authority.string_repr());
30////                headers.push(header);
31////            }
32////            None => return Err(RequestError::URIDoesNotContainAuthority),
33////        }
34//        Ok(Request {
35//            method,
36//            uri,
37//            headers,
38//            data: None,
39//        })
40//    }
41//    pub fn add_header(&mut self, header: header) {
42//        self.headers.push(header);
43//    }
44//    pub fn set_data(&mut self, data: Vec<u8>) {
45//        self.data = Some(data)
46//    }
47//    pub fn build(&self) -> String {
48//        let mut string = String::new();
49//        match &self.method {
50//            Method::GET => string.push_str("GET "),
51//            Method::POST => string.push_str("POST "),
52//            Method::HEAD => string.push_str("HEAD "),
53//        }
54//        string
55//    }
56//}