Skip to content

Commit 39c25c2

Browse files
committed
Status fn new
1 parent a174a59 commit 39c25c2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ pub fn head<T: AsRef<str>>(uri: T) -> Result<Response, error::Error> {
976976
///let response = request::post(uri, body, &mut writer).unwrap();
977977
///```
978978
pub fn post<T: AsRef<str>, U: Write>(
979-
uri: T,
979+
uri: T,
980980
body: &[u8],
981981
writer: &mut U,
982982
) -> Result<Response, error::Error> {
@@ -1329,4 +1329,4 @@ mod tests {
13291329

13301330
assert_ne!(res.status_code(), UNSUCCESS_CODE);
13311331
}
1332-
}
1332+
}

src/response.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl Response {
9292
///let response = Response::try_from(RESPONSE, &mut body).unwrap();
9393
///assert_eq!(response.status_code(), StatusCode::new(200));
9494
///```
95-
pub fn status_code(&self) -> StatusCode {
95+
pub const fn status_code(&self) -> StatusCode {
9696
self.status.code
9797
}
9898

@@ -188,6 +188,12 @@ pub struct Status {
188188
reason: String,
189189
}
190190

191+
impl Status {
192+
pub fn new(version: &str, code: StatusCode, reason: &str) -> Status {
193+
Status::from((version, code, reason))
194+
}
195+
}
196+
191197
impl<T, U, V> From<(T, U, V)> for Status
192198
where
193199
T: ToString,

0 commit comments

Comments
 (0)