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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
extern crate rand;
extern crate httparse;
extern crate tls_api;
extern crate mio;
extern crate byteorder;
extern crate libc;
extern crate fnv;
extern crate http;
extern crate itoa;
extern crate data_encoding;
extern crate smallvec;
#[cfg(test)]
#[macro_use]
extern crate matches;
#[cfg(target_os = "macos")]
extern crate core_foundation;
#[cfg(target_os = "macos")]
extern crate core_foundation_sys;
#[macro_use] extern crate failure;
#[allow(dead_code,unused_variables)]
mod dns_cache;
#[allow(dead_code,unused_variables)]
mod dns;
#[allow(dead_code)]
mod dns_parser;
#[allow(dead_code,unused_variables)]
mod con;
#[allow(dead_code,unused_variables)]
mod httpc;
#[allow(dead_code,unused_variables)]
mod call;
#[allow(dead_code,unused_variables)]
mod api;
mod types;
pub use api::*;
pub use http::{Error as HttpError};
pub use http::header::*;
pub use http::method::*;
pub use http::request::*;
pub use http::response::*;
pub use http::status::*;
pub use http::uri::*;
pub use http::version::*;
pub type Result<T> = ::std::result::Result<T,Error>;
#[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "IO error: {}", _0)]
Io (#[cause] ::std::io::Error ),
#[fail(display = "Utf8 error: {}", _0)]
Utf8 (#[cause] std::str::Utf8Error ),
#[fail(display = "FromUtf8 error: {}", _0)]
FromUtf8 (#[cause] std::string::FromUtf8Error ),
#[fail(display = "AddrParseError: {}", _0)]
Addr (#[cause] std::net::AddrParseError ),
#[fail(display = "TlsError: {}", _0)]
Tls (#[cause] tls_api::Error),
#[fail(display = "Httparse error: {}", _0)]
Httparse (#[cause] httparse::Error ),
#[fail(display = "Http error: {}", _0)]
Http (#[cause] http::Error ),
#[fail(display = "WebSocket setup failed")]
WebSocketFail(http::Response<Vec<u8>>),
#[fail(display = "Request structure did not contain body and CallSimple was used for POST/PUT.")]
MissingBody,
#[fail(display = "Response over max_response limit")]
ResponseTooBig,
#[fail(display = "Connection closed")]
Closed,
#[fail(display = "No host found in request")]
NoHost,
#[fail(display = "Invalid scheme")]
InvalidScheme,
#[fail(display = "Handshake failed")]
TlsHandshake,
#[fail(display = "Concurrent connection limit")]
NoSpace,
#[fail(display = "You must pick one of the features: native, rustls, openssl")]
NoTls,
#[fail(display = "Error parsing chunked transfer")]
ChunkedParse,
#[fail(display = "Error parsing WebSocket transfer")]
WebSocketParse,
#[fail(display = "Chunk was larger than configured CallBuilder::cunked_max_chunk. {}", _0)]
ChunkOverlimit(usize),
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<tls_api::Error> for Error {
fn from(e: tls_api::Error) -> Self {
Error::Tls(e)
}
}
impl From<httparse::Error> for Error {
fn from(e: httparse::Error) -> Self {
Error::Httparse(e)
}
}
impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
Error::Http(e)
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(e: std::string::FromUtf8Error) -> Self {
Error::FromUtf8(e)
}
}