From c9ec0956cf0cbd0655b61736c16e98947eebe6de Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 5 Jun 2019 08:12:13 +0200 Subject: [PATCH] src/backup.rs: define const PROXMOX_BACKUP_PROTOCOL_ID_V1 --- src/api2/backup.rs | 6 ++---- src/backup.rs | 2 ++ src/client/http_client.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api2/backup.rs b/src/api2/backup.rs index 3641a2e6..95026e75 100644 --- a/src/api2/backup.rs +++ b/src/api2/backup.rs @@ -51,8 +51,6 @@ fn upgrade_to_backup_protocol( rpcenv: Box, ) -> Result { - static PROXMOX_BACKUP_PROTOCOL_ID: &str = "proxmox-backup-protocol-h2"; - let debug = param["debug"].as_bool().unwrap_or(false); let store = tools::required_string_param(¶m, "store")?.to_owned(); @@ -68,7 +66,7 @@ fn upgrade_to_backup_protocol( .ok_or_else(|| format_err!("missing Upgrade header"))? .to_str()?; - if protocols != PROXMOX_BACKUP_PROTOCOL_ID { + if protocols != PROXMOX_BACKUP_PROTOCOL_ID_V1 { bail!("invalid protocol name"); } @@ -145,7 +143,7 @@ fn upgrade_to_backup_protocol( let response = Response::builder() .status(StatusCode::SWITCHING_PROTOCOLS) - .header(UPGRADE, HeaderValue::from_static(PROXMOX_BACKUP_PROTOCOL_ID)) + .header(UPGRADE, HeaderValue::from_static(PROXMOX_BACKUP_PROTOCOL_ID_V1)) .body(Body::empty())?; Ok(Box::new(futures::future::ok(response))) diff --git a/src/backup.rs b/src/backup.rs index 5f958acf..0cf8bc33 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -102,6 +102,8 @@ //! //! Not sure if this is better. TODO +pub const PROXMOX_BACKUP_PROTOCOL_ID_V1: &str = "proxmox-backup-protocol-v1"; + mod chunk_stream; pub use chunk_stream::*; diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 5d8e309d..59802c0b 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -269,7 +269,7 @@ impl HttpClient { let enc_ticket = format!("PBSAuthCookie={}", percent_encode(auth.ticket.as_bytes(), DEFAULT_ENCODE_SET)); req.headers_mut().insert("Cookie", HeaderValue::from_str(&enc_ticket).unwrap()); - req.headers_mut().insert("UPGRADE", HeaderValue::from_str("proxmox-backup-protocol-h2").unwrap()); + req.headers_mut().insert("UPGRADE", HeaderValue::from_str(crate::backup::PROXMOX_BACKUP_PROTOCOL_ID_V1).unwrap()); client.request(req) .map_err(Error::from)