src/backup.rs: define const PROXMOX_BACKUP_PROTOCOL_ID_V1

This commit is contained in:
Dietmar Maurer 2019-06-05 08:12:13 +02:00
parent 44c54845b3
commit c9ec0956cf
3 changed files with 5 additions and 5 deletions

View File

@ -51,8 +51,6 @@ fn upgrade_to_backup_protocol(
rpcenv: Box<RpcEnvironment>,
) -> Result<BoxFut, Error> {
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(&param, "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)))

View File

@ -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::*;

View File

@ -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)