Skip to content

Commit

Permalink
fix: use io.ReadAll() insteadof Body.Read().
Browse files Browse the repository at this point in the history
  • Loading branch information
yukimochi committed Nov 20, 2022
1 parent a1cccf0 commit 9bf3151
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions api/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"strconv"

"github.com/go-fed/httpsig"
"github.com/yukimochi/Activity-Relay/models"
)

func decodeActivity(request *http.Request) (*models.Activity, *models.Actor, []byte, error) {
request.Header.Set("Host", request.Host)
dataLen, _ := strconv.Atoi(request.Header.Get("Content-Length"))
body := make([]byte, dataLen)
request.Body.Read(body)
body, err := io.ReadAll(request.Body)

// Verify HTTPSignature
verifier, err := httpsig.NewVerifier(request)
Expand Down

0 comments on commit 9bf3151

Please sign in to comment.