Skip to content

Commit

Permalink
feat: add Headers::entry interface
Browse files Browse the repository at this point in the history
as well as various other header related tidying, including improving header related test coverage
  • Loading branch information
jbr committed May 31, 2024
1 parent 3fb8da6 commit 0e50558
Show file tree
Hide file tree
Showing 9 changed files with 875 additions and 212 deletions.
13 changes: 7 additions & 6 deletions http/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,14 @@ where
.try_insert_with(Date, || httpdate::fmt_http_date(SystemTime::now()));

if !matches!(self.status, Some(Status::NotModified | Status::NoContent)) {
if let Some(len) = self.body_len() {
self.response_headers
.try_insert(ContentLength, len.to_string());
}
let has_content_length = if let Some(len) = self.body_len() {
self.response_headers.try_insert(ContentLength, len);
true
} else {
self.response_headers.has_header(ContentLength)
};

if self.version == Version::Http1_1 && !self.response_headers.has_header(ContentLength)
{
if self.version == Version::Http1_1 && !has_content_length {
self.response_headers.insert(TransferEncoding, "chunked");
} else {
self.response_headers.remove(TransferEncoding);
Expand Down
Loading

0 comments on commit 0e50558

Please sign in to comment.