Skip to content

Commit

Permalink
remove more useless trailer code
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Oct 12, 2024
1 parent 1b79a1b commit 423fbe9
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lib/g3-http/src/client/adaptation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl HttpAdaptedResponse {
})?;

match name.as_str() {
"connection" | "keep-alive" | "trailer" => {
"connection" | "keep-alive" => {
// ignored hop-by-hop options
return Ok(());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/g3-http/src/server/adaptation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl HttpAdaptedRequest {
})?;

match name.as_str() {
"connection" | "keep-alive" | "te" | "trailer" => {
"connection" | "keep-alive" | "te" => {
// ignored hop-by-hop options
return Ok(());
}
Expand Down
2 changes: 0 additions & 2 deletions lib/g3-icap-client/src/parse/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ pub enum IcapLineParseError {
InvalidHeaderName,
#[error("invalid header value")]
InvalidHeaderValue,
#[error("invalid Trailer header value")]
InvalidTrailerValue,
}
13 changes: 0 additions & 13 deletions lib/g3-icap-client/src/reqmod/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub(crate) struct ReqmodResponse {
pub(crate) keep_alive: bool,
pub(crate) payload: IcapReqmodResponsePayload,
shared_headers: HttpHeaderMap,
trailers: Vec<HttpHeaderValue>,
}

impl ReqmodResponse {
Expand All @@ -43,15 +42,9 @@ impl ReqmodResponse {
keep_alive: true,
payload: IcapReqmodResponsePayload::NoPayload,
shared_headers: HttpHeaderMap::default(),
trailers: Vec::new(),
}
}

#[allow(dead_code)]
pub(crate) fn take_trailers(&mut self) -> Vec<HttpHeaderValue> {
self.trailers.drain(..).collect()
}

pub(crate) fn take_shared_headers(&mut self) -> HttpHeaderMap {
std::mem::take(&mut self.shared_headers)
}
Expand Down Expand Up @@ -151,12 +144,6 @@ impl ReqmodResponse {
}
}
}
"trailer" => {
let value = HttpHeaderValue::from_str(header.value).map_err(|_| {
IcapReqmodParseError::InvalidHeaderLine(IcapLineParseError::InvalidTrailerValue)
})?;
self.trailers.push(value);
}
"encapsulated" => self.payload = IcapReqmodResponsePayload::parse(header.value)?,
header_name => {
if shared_names.contains(header_name) {
Expand Down
20 changes: 1 addition & 19 deletions lib/g3-icap-client/src/respmod/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@
* limitations under the License.
*/

use std::str::FromStr;

use tokio::io::AsyncBufRead;

use g3_io_ext::LimitedBufReadExt;
use g3_types::net::HttpHeaderValue;

use super::{IcapRespmodParseError, IcapRespmodResponsePayload};
use crate::parse::{HeaderLine, IcapLineParseError, StatusLine};
use crate::parse::{HeaderLine, StatusLine};

pub(crate) struct RespmodResponse {
pub(crate) code: u16,
pub(crate) reason: String,
pub(crate) keep_alive: bool,
pub(crate) payload: IcapRespmodResponsePayload,
trailers: Vec<HttpHeaderValue>,
}

impl RespmodResponse {
Expand All @@ -39,15 +35,9 @@ impl RespmodResponse {
reason,
keep_alive: true,
payload: IcapRespmodResponsePayload::NoPayload,
trailers: Vec::new(),
}
}

#[allow(dead_code)]
pub(crate) fn take_trailers(&mut self) -> Vec<HttpHeaderValue> {
self.trailers.drain(..).collect()
}

pub(crate) async fn parse<R>(
reader: &mut R,
max_header_size: usize,
Expand Down Expand Up @@ -138,14 +128,6 @@ impl RespmodResponse {
}
}
}
"trailer" => {
let value = HttpHeaderValue::from_str(header.value).map_err(|_| {
IcapRespmodParseError::InvalidHeaderLine(
IcapLineParseError::InvalidTrailerValue,
)
})?;
self.trailers.push(value);
}
"encapsulated" => self.payload = IcapRespmodResponsePayload::parse(header.value)?,
_ => {}
}
Expand Down

0 comments on commit 423fbe9

Please sign in to comment.