mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 22:10:01 -04:00
send empty content-length
This commit is contained in:
parent
4c19b207bf
commit
b6453af53a
4 changed files with 21 additions and 12 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
|
@ -683,7 +683,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epoxy-client"
|
name = "epoxy-client"
|
||||||
version = "2.1.5"
|
version = "2.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "epoxy-client"
|
name = "epoxy-client"
|
||||||
version = "2.1.5"
|
version = "2.1.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mercuryworkshop/epoxy-tls",
|
"name": "@mercuryworkshop/epoxy-tls",
|
||||||
"version": "2.1.5-1",
|
"version": "2.1.6-1",
|
||||||
"description": "A wasm library for using raw encrypted tls/ssl/tcp/udp/https/websocket streams on the browser",
|
"description": "A wasm library for using raw encrypted tls/ssl/tcp/udp/https/websocket streams on the browser",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./build.sh"
|
"build": "./build.sh"
|
||||||
|
|
|
@ -9,7 +9,10 @@ use cfg_if::cfg_if;
|
||||||
use futures_util::future::Either;
|
use futures_util::future::Either;
|
||||||
use futures_util::TryStreamExt;
|
use futures_util::TryStreamExt;
|
||||||
use http::{
|
use http::{
|
||||||
header::{InvalidHeaderName, InvalidHeaderValue},
|
header::{
|
||||||
|
InvalidHeaderName, InvalidHeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH,
|
||||||
|
CONTENT_TYPE, HOST, USER_AGENT,
|
||||||
|
},
|
||||||
method::InvalidMethod,
|
method::InvalidMethod,
|
||||||
uri::{InvalidUri, InvalidUriParts},
|
uri::{InvalidUri, InvalidUriParts},
|
||||||
HeaderName, HeaderValue, Method, Request, Response,
|
HeaderName, HeaderValue, Method, Request, Response,
|
||||||
|
@ -573,7 +576,9 @@ impl EpoxyClient {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut request_builder = Request::builder().uri(url.clone()).method(request_method);
|
let mut request_builder = Request::builder()
|
||||||
|
.uri(url.clone())
|
||||||
|
.method(request_method.clone());
|
||||||
|
|
||||||
// Generic InvalidRequest because this only returns None if the builder has some error
|
// Generic InvalidRequest because this only returns None if the builder has some error
|
||||||
// which we don't know
|
// which we don't know
|
||||||
|
@ -583,20 +588,20 @@ impl EpoxyClient {
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(feature = "full")] {
|
if #[cfg(feature = "full")] {
|
||||||
headers_map.insert("Accept-Encoding", HeaderValue::from_static("gzip, br"));
|
headers_map.insert(ACCEPT_ENCODING, HeaderValue::from_static("gzip, br"));
|
||||||
} else {
|
} else {
|
||||||
headers_map.insert("Accept-Encoding", HeaderValue::from_static("identity"));
|
headers_map.insert(ACCEPT_ENCODING, HeaderValue::from_static("identity"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers_map.insert("Connection", HeaderValue::from_static("keep-alive"));
|
headers_map.insert(CONNECTION, HeaderValue::from_static("keep-alive"));
|
||||||
headers_map.insert("User-Agent", HeaderValue::from_str(&self.user_agent)?);
|
headers_map.insert(USER_AGENT, HeaderValue::from_str(&self.user_agent)?);
|
||||||
headers_map.insert(
|
headers_map.insert(
|
||||||
"Host",
|
HOST,
|
||||||
HeaderValue::from_str(&format!("{}{}", host, port_str))?,
|
HeaderValue::from_str(&format!("{}{}", host, port_str))?,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(content_type) = body_content_type {
|
if let Some(content_type) = body_content_type {
|
||||||
headers_map.insert("Content-Type", HeaderValue::from_str(&content_type)?);
|
headers_map.insert(CONTENT_TYPE, HeaderValue::from_str(&content_type)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(headers) = headers {
|
if let Some(headers) = headers {
|
||||||
|
@ -608,6 +613,10 @@ impl EpoxyClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches!(request_method, Method::POST | Method::PUT | Method::PATCH) && body.is_empty() {
|
||||||
|
headers_map.insert(CONTENT_LENGTH, 0.into());
|
||||||
|
}
|
||||||
|
|
||||||
let (mut response, response_uri, redirected) = self
|
let (mut response, response_uri, redirected) = self
|
||||||
.send_req(request_builder.body(HttpBody::new(body))?, request_redirect)
|
.send_req(request_builder.body(HttpBody::new(body))?, request_redirect)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue