Coverage Report

Created: 2026-06-14 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-0.13.4/src/response.rs
Line
Count
Source
1
use url::Url;
2
3
#[derive(Debug, Clone, PartialEq)]
4
pub(crate) struct ResponseUrl(pub Url);
5
6
/// Extension trait for http::response::Builder objects
7
///
8
/// Allows the user to add a `Url` to the http::Response
9
pub trait ResponseBuilderExt {
10
    /// A builder method for the `http::response::Builder` type that allows the user to add a `Url`
11
    /// to the `http::Response`
12
    fn url(self, url: Url) -> Self;
13
}
14
15
impl ResponseBuilderExt for http::response::Builder {
16
0
    fn url(self, url: Url) -> Self {
17
0
        self.extension(ResponseUrl(url))
18
0
    }
19
}
20
21
#[cfg(test)]
22
mod tests {
23
    use super::{ResponseBuilderExt, ResponseUrl};
24
    use http::response::Builder;
25
    use url::Url;
26
27
    #[test]
28
    fn test_response_builder_ext() {
29
        let url = Url::parse("http://example.com").unwrap();
30
        let response = Builder::new()
31
            .status(200)
32
            .url(url.clone())
33
            .body(())
34
            .unwrap();
35
36
        assert_eq!(
37
            response.extensions().get::<ResponseUrl>(),
38
            Some(&ResponseUrl(url))
39
        );
40
    }
41
}