1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

Update base64 to 0.21 (#2966)

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
citreae535
2023-01-21 09:36:08 +08:00
committed by GitHub
parent 2f0b8a264a
commit b00fe72cf6
8 changed files with 18 additions and 9 deletions

View File

@ -63,7 +63,7 @@ actix-tls = { version = "3", features = ["connect", "uri"] }
actix-utils = "3"
ahash = "0.7"
base64 = "0.13"
base64 = "0.21"
bytes = "1"
cfg-if = "1"
derive_more = "0.99.5"

View File

@ -1,5 +1,7 @@
use std::{convert::TryFrom, fmt, net::IpAddr, rc::Rc, time::Duration};
use base64::prelude::*;
use actix_http::{
error::HttpError,
header::{self, HeaderMap, HeaderName, TryIntoHeaderPair},
@ -210,7 +212,7 @@ where
};
self.add_default_header((
header::AUTHORIZATION,
format!("Basic {}", base64::encode(auth)),
format!("Basic {}", BASE64_STANDARD.encode(auth)),
))
}

View File

@ -1,5 +1,6 @@
use std::{convert::TryFrom, fmt, net, rc::Rc, time::Duration};
use base64::prelude::*;
use bytes::Bytes;
use futures_core::Stream;
use serde::Serialize;
@ -238,7 +239,7 @@ impl ClientRequest {
self.insert_header((
header::AUTHORIZATION,
format!("Basic {}", base64::encode(auth)),
format!("Basic {}", BASE64_STANDARD.encode(auth)),
))
}

View File

@ -28,6 +28,8 @@
use std::{convert::TryFrom, fmt, net::SocketAddr, str};
use base64::prelude::*;
use actix_codec::Framed;
use actix_http::{ws, Payload, RequestHead};
use actix_rt::time::timeout;
@ -236,7 +238,10 @@ impl WebsocketsRequest {
Some(password) => format!("{}:{}", username, password),
None => format!("{}:", username),
};
self.header(AUTHORIZATION, format!("Basic {}", base64::encode(auth)))
self.header(
AUTHORIZATION,
format!("Basic {}", BASE64_STANDARD.encode(auth)),
)
}
/// Set HTTP bearer authentication header
@ -321,7 +326,7 @@ impl WebsocketsRequest {
// Generate a random key for the `Sec-WebSocket-Key` header which is a base64-encoded
// (see RFC 4648 §4) value that, when decoded, is 16 bytes in length (RFC 6455 §1.3).
let sec_key: [u8; 16] = rand::random();
let key = base64::encode(sec_key);
let key = BASE64_STANDARD.encode(sec_key);
self.head.headers.insert(
header::SEC_WEBSOCKET_KEY,

View File

@ -13,6 +13,7 @@ use std::{
};
use actix_utils::future::ok;
use base64::prelude::*;
use bytes::Bytes;
use cookie::Cookie;
use futures_util::stream;
@ -783,7 +784,7 @@ async fn client_basic_auth() {
.unwrap()
.to_str()
.unwrap()
== format!("Basic {}", base64::encode("username:password"))
== format!("Basic {}", BASE64_STANDARD.encode("username:password"))
{
HttpResponse::Ok()
} else {