chore: Update to base64 0.21 (#1228)
This commit is contained in:
@@ -2,6 +2,7 @@ use std::error::Error;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use base64::Engine as _;
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use futures_core::{ready, Stream};
|
||||
use http::{header, HeaderMap, HeaderValue};
|
||||
@@ -100,7 +101,8 @@ impl<B> GrpcWebCall<B> {
|
||||
// returned `Bytes`, keeping the rest for the next attempt to decode.
|
||||
let index = self.max_decodable();
|
||||
|
||||
base64::decode(self.as_mut().project().buf.split_to(index))
|
||||
crate::util::base64::STANDARD
|
||||
.decode(self.as_mut().project().buf.split_to(index))
|
||||
.map(|decoded| Some(Bytes::from(decoded)))
|
||||
.map_err(internal_error)
|
||||
}
|
||||
@@ -151,7 +153,7 @@ where
|
||||
|
||||
if let Some(mut res) = ready!(this.inner.as_mut().poll_data(cx)) {
|
||||
if *this.encoding == Encoding::Base64 {
|
||||
res = res.map(|b| base64::encode(b).into())
|
||||
res = res.map(|b| crate::util::base64::STANDARD.encode(b).into())
|
||||
}
|
||||
|
||||
return Poll::Ready(Some(res.map_err(internal_error)));
|
||||
@@ -165,7 +167,7 @@ where
|
||||
let mut frame = make_trailers_frame(map);
|
||||
|
||||
if *this.encoding == Encoding::Base64 {
|
||||
frame = base64::encode(frame).into_bytes();
|
||||
frame = crate::util::base64::STANDARD.encode(frame).into_bytes();
|
||||
}
|
||||
|
||||
*this.poll_trailers = false;
|
||||
|
||||
@@ -139,3 +139,22 @@ where
|
||||
)
|
||||
.layer(GrpcWebService::new(service))
|
||||
}
|
||||
|
||||
pub(crate) mod util {
|
||||
pub(crate) mod base64 {
|
||||
use base64::{
|
||||
alphabet,
|
||||
engine::{
|
||||
general_purpose::{GeneralPurpose, GeneralPurposeConfig},
|
||||
DecodePaddingMode,
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) const STANDARD: GeneralPurpose = GeneralPurpose::new(
|
||||
&alphabet::STANDARD,
|
||||
GeneralPurposeConfig::new()
|
||||
.with_encode_padding(true)
|
||||
.with_decode_padding_mode(DecodePaddingMode::Indifferent),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user