Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions github/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,16 @@ pub use reqwest::{header::HeaderMap, StatusCode};
pub struct Response<T> {
pub status: reqwest::StatusCode,
pub headers: reqwest::header::HeaderMap,
pub extensions: http::Extensions,
pub body: T,
}

impl<T> Response<T> {
pub fn new(status: reqwest::StatusCode, headers: reqwest::header::HeaderMap, body: T) -> Self {
pub fn new(status: reqwest::StatusCode, headers: reqwest::header::HeaderMap, extensions: http::Extensions, body: T) -> Self {
Self {
status,
headers,
extensions,
body,
}
}
Expand Down Expand Up @@ -663,6 +665,7 @@ impl Client {

let status = response.status();
let headers = response.headers().clone();
let extensions = response.extensions().to_owned();
let link = response
.headers()
.get(http::header::LINK)
Expand Down Expand Up @@ -698,7 +701,7 @@ impl Client {
};
Ok((
next_link,
crate::Response::new(status, headers, parsed_response),
crate::Response::new(status, headers, extensions, parsed_response),
))
} else if status.is_redirection() {
match status {
Expand All @@ -716,7 +719,7 @@ impl Client {
.lookup_next_link(&uri)
.map(|next_link| next_link.map(crate::utils::NextLink)),
};
link.map(|link| (link, Response::new(status, headers, out)))
link.map(|link| (link, Response::new(status, headers, extensions, out)))
}
#[cfg(not(feature = "httpcache"))]
{
Expand All @@ -734,7 +737,7 @@ impl Client {
serde_json::from_slice::<Out>(&response_body)?
};

Ok((None, crate::Response::new(status, headers, body)))
Ok((None, crate::Response::new(status, headers, extensions, body)))
}
}
} else {
Expand Down Expand Up @@ -974,6 +977,7 @@ impl Client {
Ok(Response::new(
response.status,
response.headers,
response.extensions.to_owned(),
global_items,
))
}
Expand Down