Skip to content

Commit 3511d9c

Browse files
committed
irondrop: append date
1 parent a4bef71 commit 3511d9c

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/http.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,16 @@ where
454454
",
455455
);
456456

457+
let has_date = response
458+
.headers
459+
.keys()
460+
.any(|k| k.eq_ignore_ascii_case("date"));
461+
if !has_date {
462+
if let Some(date_str) = crate::webdav::format_http_date_now() {
463+
response_str.push_str(&format!("Date: {}\r\n", date_str));
464+
}
465+
}
466+
457467
for (key, value) in &response.headers {
458468
response_str.push_str(&format!(
459469
"{key}: {value}

src/webdav.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,10 @@ fn xml_escape(value: &str) -> String {
24682468
.replace('\'', "'")
24692469
}
24702470

2471+
pub fn format_http_date_now() -> Option<String> {
2472+
format_http_date(SystemTime::now())
2473+
}
2474+
24712475
fn format_http_date(time: SystemTime) -> Option<String> {
24722476
const WEEKDAYS: [&str; 7] = ["Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"];
24732477
const MONTHS: [&str; 12] = [

0 commit comments

Comments
 (0)