diff --git a/handlers/data/data.go b/handlers/data/data.go index b9c3dd9..1096e9e 100644 --- a/handlers/data/data.go +++ b/handlers/data/data.go @@ -216,7 +216,7 @@ func getData(postID string) (gjson.Result, error) { // Scrape from GraphQL API if videoBlocked || len(username) == 0 { - gqlValue, err := parseGQLData(postID, req, res) + gqlValue, err := parseGQLData(postID) if err != nil { log.Error().Str("postID", postID).Err(err).Msg("Failed to parse data from parseGQLData") return gjsonNil, err @@ -306,9 +306,8 @@ func parseEmbedHTML(embedHTML []byte) (string, error) { }`, nil } -func parseGQLData(postID string, req *fasthttp.Request, res *fasthttp.Response) ([]byte, error) { - req.Reset() - res.Reset() +func parseGQLData(postID string) ([]byte, error) { + req, res := fasthttp.AcquireRequest(), fasthttp.AcquireResponse() req.Header.SetMethod("POST") req.Header.Set("accept", "*/*") @@ -364,5 +363,9 @@ func parseGQLData(postID string, req *fasthttp.Request, res *fasthttp.Response) if err := client.DoTimeout(req, res, timeout); err != nil { return nil, err } - return res.Body(), nil + + var newBytes []byte + // Copy body to newBytes + newBytes = append(newBytes, res.Body()...) + return newBytes, nil }