chore(web): Update to base64 0.21 (#1235)
This commit is contained in:
@@ -7,7 +7,7 @@ version = "0.1.0"
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.13"
|
base64 = "0.21"
|
||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
hyper = "0.14"
|
hyper = "0.14"
|
||||||
prost = "0.11"
|
prost = "0.11"
|
||||||
|
|||||||
@@ -67,3 +67,22 @@ impl Test for Svc {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod util {
|
||||||
|
pub mod base64 {
|
||||||
|
use base64::{
|
||||||
|
alphabet,
|
||||||
|
engine::{
|
||||||
|
general_purpose::{GeneralPurpose, GeneralPurposeConfig},
|
||||||
|
DecodePaddingMode,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const STANDARD: GeneralPurpose = GeneralPurpose::new(
|
||||||
|
&alphabet::STANDARD,
|
||||||
|
GeneralPurposeConfig::new()
|
||||||
|
.with_encode_padding(true)
|
||||||
|
.with_decode_padding_mode(DecodePaddingMode::Indifferent),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
use base64::Engine as _;
|
||||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||||
use hyper::http::{header, StatusCode};
|
use hyper::http::{header, StatusCode};
|
||||||
use hyper::{Body, Client, Method, Request, Uri};
|
use hyper::{Body, Client, Method, Request, Uri};
|
||||||
@@ -110,7 +111,9 @@ fn build_request(base_uri: String, content_type: &str, accept: &str) -> Request<
|
|||||||
|
|
||||||
let bytes = match content_type {
|
let bytes = match content_type {
|
||||||
"grpc-web" => encode_body(),
|
"grpc-web" => encode_body(),
|
||||||
"grpc-web-text" => base64::encode(encode_body()).into(),
|
"grpc-web-text" => integration::util::base64::STANDARD
|
||||||
|
.encode(encode_body())
|
||||||
|
.into(),
|
||||||
_ => panic!("invalid content type {}", content_type),
|
_ => panic!("invalid content type {}", content_type),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,7 +131,10 @@ async fn decode_body(body: Body, content_type: &str) -> (Output, Bytes) {
|
|||||||
let mut body = hyper::body::to_bytes(body).await.unwrap();
|
let mut body = hyper::body::to_bytes(body).await.unwrap();
|
||||||
|
|
||||||
if content_type == "application/grpc-web-text+proto" {
|
if content_type == "application/grpc-web-text+proto" {
|
||||||
body = base64::decode(body).unwrap().into()
|
body = integration::util::base64::STANDARD
|
||||||
|
.decode(body)
|
||||||
|
.unwrap()
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
body.advance(1);
|
body.advance(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user