1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-20 09:18:26 +00: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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 9 deletions

View file

@ -37,7 +37,6 @@ actix-rt = "2.2"
actix-server = "2"
awc = { version = "3", default-features = false }
base64 = "0.13"
bytes = "1"
futures-core = { version = "0.3.17", default-features = false }
http = "0.2.5"

View file

@ -86,7 +86,7 @@ h2 = { version = "0.3.9", optional = true }
# websockets
local-channel = { version = "0.1", optional = true }
base64 = { version = "0.13", optional = true }
base64 = { version = "0.21", optional = true }
rand = { version = "0.8", optional = true }
sha1 = { version = "0.10", optional = true }

View file

@ -3,6 +3,7 @@ use std::{
fmt,
};
use base64::prelude::*;
use tracing::error;
/// Operation codes defined in [RFC 6455 §11.8].
@ -244,7 +245,7 @@ pub fn hash_key(key: &[u8]) -> [u8; 28] {
};
let mut hash_b64 = [0; 28];
let n = base64::encode_config_slice(hash, base64::STANDARD, &mut hash_b64);
let n = BASE64_STANDARD.encode_slice(hash, &mut hash_b64).unwrap();
assert_eq!(n, 28);
hash_b64

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 {