Add host to signatures
This commit is contained in:
@@ -96,6 +96,9 @@ pub enum MyError {
|
||||
#[error("Response from {0} has invalid status code, {1}")]
|
||||
Status(String, StatusCode),
|
||||
|
||||
#[error("Uri {0} is missing host")]
|
||||
Host(String),
|
||||
|
||||
#[error("Expected an Object, found something else")]
|
||||
ObjectFormat,
|
||||
|
||||
|
||||
+24
-6
@@ -77,8 +77,14 @@ impl Requests {
|
||||
let signer = self.signer();
|
||||
|
||||
let client: Client = self.client.borrow().clone();
|
||||
let res = client
|
||||
.get(url)
|
||||
let req = client.get(url);
|
||||
let host = req
|
||||
.get_uri()
|
||||
.host()
|
||||
.ok_or(MyError::Host(url.to_string()))?
|
||||
.to_string();
|
||||
let res = req
|
||||
.header("Host", host)
|
||||
.header("Accept", accept)
|
||||
.set(Date(SystemTime::now().into()))
|
||||
.signature(
|
||||
@@ -123,8 +129,14 @@ impl Requests {
|
||||
let signer = self.signer();
|
||||
|
||||
let client: Client = self.client.borrow().clone();
|
||||
let res = client
|
||||
.get(url)
|
||||
let req = client.get(url);
|
||||
let host = req
|
||||
.get_uri()
|
||||
.host()
|
||||
.ok_or(MyError::Host(url.to_string()))?
|
||||
.to_string();
|
||||
let res = req
|
||||
.header("Host", host)
|
||||
.header("Accept", "*/*")
|
||||
.set(Date(SystemTime::now().into()))
|
||||
.signature(
|
||||
@@ -184,8 +196,14 @@ impl Requests {
|
||||
let item_string = serde_json::to_string(item)?;
|
||||
|
||||
let client: Client = self.client.borrow().clone();
|
||||
let res = client
|
||||
.post(inbox.as_str())
|
||||
let req = client.post(inbox.as_str());
|
||||
let host = req
|
||||
.get_uri()
|
||||
.host()
|
||||
.ok_or(MyError::Host(inbox.to_string()))?
|
||||
.to_string();
|
||||
let res = req
|
||||
.header("Host", host)
|
||||
.header("Accept", "application/activity+json")
|
||||
.header("Content-Type", "application/activity+json")
|
||||
.set(Date(SystemTime::now().into()))
|
||||
|
||||
Reference in New Issue
Block a user