read_url/http/
http_url.rs1use super::super::{context::*, url::*};
2
3use std::fmt;
4
5#[derive(Clone, Debug)]
17pub struct HttpUrl {
18 pub url: url::Url,
20
21 pub(crate) context: UrlContextRef,
22}
23
24impl HttpUrl {
25 pub fn new(context: &UrlContextRef, url: url::Url) -> Self {
27 Self { url, context: context.clone() }
28 }
29
30 pub fn new_with(&self, path: &str) -> Self {
32 let mut url = self.url.clone();
33 url.set_path(path);
34 url.set_query(None);
35 url.set_fragment(None);
36 Self::new(&self.context, url)
37 }
38}
39
40impl fmt::Display for HttpUrl {
41 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
42 write!(formatter, "{}", self.url)
43 }
44}
45
46impl Into<UrlRef> for HttpUrl {
49 fn into(self) -> UrlRef {
50 Box::new(self)
51 }
52}