Fix rfc9421 requests having bad headers
This commit is contained in:
parent
f580a116f2
commit
9c3242f823
1 changed files with 5 additions and 1 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yaronf/httpsign"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
|
@ -41,9 +42,10 @@ func RequestSigned(
|
|||
actor *models.User,
|
||||
) (response *http.Response, wasRfc9421 bool, err error) {
|
||||
res, err := RequestSignedRFC9421(method, target, body, actor)
|
||||
if err == nil {
|
||||
if err == nil && res.StatusCode >= 200 && res.StatusCode < 400 {
|
||||
return res, true, nil
|
||||
}
|
||||
log.Debug().Str("target", target).Msg("RFC9421 signed request failed, trying cavage signed")
|
||||
res, err = RequestSignedCavage(method, target, body, actor)
|
||||
return res, false, err
|
||||
}
|
||||
|
@ -59,6 +61,8 @@ func RequestSignedRFC9421(
|
|||
return nil, err
|
||||
}
|
||||
applyDefaultHeaders(req)
|
||||
req.Header.Add("Accept", "application/activity+json")
|
||||
req.Header.Add("Content-Type", "application/activity+json")
|
||||
var signer *httpsign.Signer
|
||||
signerFields := httpsign.Headers("@request-target", "content-digest")
|
||||
if config.GlobalConfig.Experimental.UseEd25519Keys {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue