src/backup.rs: define const PROXMOX_BACKUP_PROTOCOL_ID_V1
This commit is contained in:
parent
44c54845b3
commit
c9ec0956cf
@ -51,8 +51,6 @@ fn upgrade_to_backup_protocol(
|
|||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
static PROXMOX_BACKUP_PROTOCOL_ID: &str = "proxmox-backup-protocol-h2";
|
|
||||||
|
|
||||||
let debug = param["debug"].as_bool().unwrap_or(false);
|
let debug = param["debug"].as_bool().unwrap_or(false);
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?.to_owned();
|
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"))?
|
.ok_or_else(|| format_err!("missing Upgrade header"))?
|
||||||
.to_str()?;
|
.to_str()?;
|
||||||
|
|
||||||
if protocols != PROXMOX_BACKUP_PROTOCOL_ID {
|
if protocols != PROXMOX_BACKUP_PROTOCOL_ID_V1 {
|
||||||
bail!("invalid protocol name");
|
bail!("invalid protocol name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +143,7 @@ fn upgrade_to_backup_protocol(
|
|||||||
|
|
||||||
let response = Response::builder()
|
let response = Response::builder()
|
||||||
.status(StatusCode::SWITCHING_PROTOCOLS)
|
.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())?;
|
.body(Body::empty())?;
|
||||||
|
|
||||||
Ok(Box::new(futures::future::ok(response)))
|
Ok(Box::new(futures::future::ok(response)))
|
||||||
|
@ -102,6 +102,8 @@
|
|||||||
//!
|
//!
|
||||||
//! Not sure if this is better. TODO
|
//! Not sure if this is better. TODO
|
||||||
|
|
||||||
|
pub const PROXMOX_BACKUP_PROTOCOL_ID_V1: &str = "proxmox-backup-protocol-v1";
|
||||||
|
|
||||||
mod chunk_stream;
|
mod chunk_stream;
|
||||||
pub use chunk_stream::*;
|
pub use chunk_stream::*;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ impl HttpClient {
|
|||||||
|
|
||||||
let enc_ticket = format!("PBSAuthCookie={}", percent_encode(auth.ticket.as_bytes(), DEFAULT_ENCODE_SET));
|
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("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)
|
client.request(req)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
|
Loading…
Reference in New Issue
Block a user