mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-27 22:31:01 +00:00
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:
parent
33baca81d8
commit
712cc328e1
4 changed files with 6 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -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",
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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![])?;
|
||||||
|
|
|
@ -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)?;
|
||||||
|
|
Loading…
Reference in a new issue