Improvements http2 transport protocol
This commit is contained in:
parent
cab43376e8
commit
c06e4e4945
2 changed files with 13 additions and 10 deletions
|
@ -119,12 +119,14 @@ pub async fn connect(
|
||||||
.header(CONTENT_TYPE, "application/json")
|
.header(CONTENT_TYPE, "application/json")
|
||||||
.version(hyper::Version::HTTP_2);
|
.version(hyper::Version::HTTP_2);
|
||||||
|
|
||||||
|
let headers = req.headers_mut().unwrap();
|
||||||
for (k, v) in &client_cfg.http_headers {
|
for (k, v) in &client_cfg.http_headers {
|
||||||
let _ = req.headers_mut().unwrap().remove(k);
|
let _ = headers.remove(k);
|
||||||
req = req.header(k, v);
|
headers.append(k, v.clone());
|
||||||
}
|
}
|
||||||
if let Some(auth) = &client_cfg.http_upgrade_credentials {
|
if let Some(auth) = &client_cfg.http_upgrade_credentials {
|
||||||
req = req.header(AUTHORIZATION, auth);
|
let _ = headers.remove(AUTHORIZATION);
|
||||||
|
headers.append(AUTHORIZATION, auth.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let (tx, rx) = mpsc::channel::<Bytes>(1024);
|
let (tx, rx) = mpsc::channel::<Bytes>(1024);
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::io;
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use tokio::io::{AsyncWrite, AsyncWriteExt, ReadHalf, WriteHalf};
|
use tokio::io::{AsyncWrite, AsyncWriteExt, ReadHalf, WriteHalf};
|
||||||
use tracing::{error, trace};
|
use tracing::trace;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub struct WebsocketTunnelWrite {
|
pub struct WebsocketTunnelWrite {
|
||||||
|
@ -59,7 +59,6 @@ impl TunnelWrite for WebsocketTunnelWrite {
|
||||||
if buf.capacity() == read_len {
|
if buf.capacity() == read_len {
|
||||||
let new_size = buf.capacity() + (buf.capacity() / 4); // grow buffer by 1.25 %
|
let new_size = buf.capacity() + (buf.capacity() / 4); // grow buffer by 1.25 %
|
||||||
buf.reserve(new_size);
|
buf.reserve(new_size);
|
||||||
buf.resize(buf.capacity(), 0);
|
|
||||||
trace!(
|
trace!(
|
||||||
"Buffer {} Mb {} {} {}",
|
"Buffer {} Mb {} {} {}",
|
||||||
buf.capacity() as f64 / 1024.0 / 1024.0,
|
buf.capacity() as f64 / 1024.0 / 1024.0,
|
||||||
|
@ -103,8 +102,8 @@ impl WebsocketTunnelRead {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_reader(x: Frame<'_>) -> futures_util::future::Ready<anyhow::Result<()>> {
|
fn frame_reader(_: Frame<'_>) -> futures_util::future::Ready<anyhow::Result<()>> {
|
||||||
error!("frame {:?} {:?}", x.opcode, x.payload);
|
//error!("frame {:?} {:?}", x.opcode, x.payload);
|
||||||
futures_util::future::ready(anyhow::Ok(()))
|
futures_util::future::ready(anyhow::Ok(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,12 +155,14 @@ pub async fn connect(
|
||||||
)
|
)
|
||||||
.version(hyper::Version::HTTP_11);
|
.version(hyper::Version::HTTP_11);
|
||||||
|
|
||||||
|
let headers = req.headers_mut().unwrap();
|
||||||
for (k, v) in &client_cfg.http_headers {
|
for (k, v) in &client_cfg.http_headers {
|
||||||
let _ = req.headers_mut().unwrap().remove(k);
|
let _ = headers.remove(k);
|
||||||
req = req.header(k, v);
|
headers.append(k, v.clone());
|
||||||
}
|
}
|
||||||
if let Some(auth) = &client_cfg.http_upgrade_credentials {
|
if let Some(auth) = &client_cfg.http_upgrade_credentials {
|
||||||
req = req.header(AUTHORIZATION, auth);
|
let _ = headers.remove(AUTHORIZATION);
|
||||||
|
headers.append(AUTHORIZATION, auth.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let req = req.body(Empty::<Bytes>::new()).with_context(|| {
|
let req = req.body(Empty::<Bytes>::new()).with_context(|| {
|
||||||
|
|
Loading…
Reference in a new issue