make sure URI paths start with a slash

Otherwise we get an empty error message.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-05-07 08:41:20 +02:00
parent 3e234af16e
commit c4e1af3069

View File

@ -277,15 +277,15 @@ fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(Stri
} }
fn build_uri(server: &str, port: u16, path: &str, query: Option<String>) -> Result<Uri, Error> { fn build_uri(server: &str, port: u16, path: &str, query: Option<String>) -> Result<Uri, Error> {
let builder = Uri::builder() Uri::builder()
.scheme("https") .scheme("https")
.authority(build_authority(server, port)?); .authority(build_authority(server, port)?)
match query { .path_and_query(match query {
Some(query) => builder.path_and_query(format!("{}?{}", path, query)), Some(query) => format!("/{}?{}", path, query),
None => builder.path_and_query(path), None => format!("/{}", path),
} })
.build() .build()
.map_err(Error::from) .map_err(|err| format_err!("error building uri - {}", err))
} }
impl HttpClient { impl HttpClient {