fetch, send: use httpdate for formatting Date: header

> Oct 07 03:25:59 buzzrelay buzzrelay[676]: 2023-10-07T01:25:59.381211Z ERROR buzzrelay::relay: relay::send Response("{\"error\":\"Invalid Date header: not RFC 2616 compliant date: \\\"Sat, 7 Oct 2023 01:25:58 GMT\\\"\"}")

is it the leading 0 in the day position?
This commit is contained in:
Astro 2023-10-07 03:25:43 +02:00
parent 33baca81d8
commit 712cc328e1
4 changed files with 6 additions and 5 deletions

1
Cargo.lock generated
View file

@ -283,6 +283,7 @@ dependencies = [
"futures", "futures",
"http", "http",
"http_digest_headers", "http_digest_headers",
"httpdate",
"metrics", "metrics",
"metrics-exporter-prometheus", "metrics-exporter-prometheus",
"metrics-util", "metrics-util",

View file

@ -31,3 +31,4 @@ metrics-util = "0.15"
metrics-exporter-prometheus = "0.12" metrics-exporter-prometheus = "0.12"
deunicode = "1.3" deunicode = "1.3"
urlencoding = "2" urlencoding = "2"
httpdate = "1"

View file

@ -1,3 +1,4 @@
use std::time::SystemTime;
use http::StatusCode; use http::StatusCode;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use sigh::{PrivateKey, SigningConfig, alg::RsaSha256}; use sigh::{PrivateKey, SigningConfig, alg::RsaSha256};
@ -21,8 +22,7 @@ where
.uri(uri) .uri(uri)
.header("host", &host) .header("host", &host)
.header("content-type", "application/activity+json") .header("content-type", "application/activity+json")
.header("date", chrono::Utc::now().to_rfc2822() .header("date", httpdate::fmt_http_date(SystemTime::now()))
.replace("+0000", "GMT"))
.header("accept", "application/activity+json") .header("accept", "application/activity+json")
.header("digest", digest_header) .header("digest", digest_header)
.body(vec![])?; .body(vec![])?;

View file

@ -1,6 +1,6 @@
use std::{ use std::{
sync::Arc, sync::Arc,
time::Instant, time::{Instant, SystemTime},
}; };
use http::StatusCode; use http::StatusCode;
use metrics::histogram; use metrics::histogram;
@ -39,8 +39,7 @@ pub async fn send_raw(
.uri(uri) .uri(uri)
.header("host", &host) .header("host", &host)
.header("content-type", "application/activity+json") .header("content-type", "application/activity+json")
.header("date", chrono::Utc::now().to_rfc2822() .header("date", httpdate::fmt_http_date(SystemTime::now()))
.replace("+0000", "GMT"))
.header("digest", digest_header) .header("digest", digest_header)
.body(body.as_ref().clone()) .body(body.as_ref().clone())
.map_err(Error::HttpReq)?; .map_err(Error::HttpReq)?;