Skip to content

Commit 9aa8db8

Browse files
authored
use asset client for giphy in url srv (keybase#17597)
1 parent 9b0ef5a commit 9aa8db8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎go/chat/attachment_httpsrv.go‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"sync"
1414
"time"
1515

16+
"github.com/keybase/client/go/chat/giphy"
17+
1618
lru "github.com/hashicorp/golang-lru"
1719
"github.com/keybase/client/go/chat/attachments"
1820
"github.com/keybase/client/go/chat/globals"
@@ -391,15 +393,21 @@ func (r *AttachmentHTTPSrv) serveGiphyLink(w http.ResponseWriter, req *http.Requ
391393
}
392394
// Grab range headers
393395
rangeHeader := req.Header.Get("Range")
394-
client := &http.Client{}
395-
giphyReq, err := http.NewRequest("GET", val.(string), nil)
396+
client := giphy.AssetClient()
397+
url, err := giphy.ProxyURL(val.(string))
398+
if err != nil {
399+
r.makeError(ctx, w, http.StatusInternalServerError, "url creation: %s", err)
400+
return
401+
}
402+
giphyReq, err := http.NewRequest("GET", url, nil)
396403
if err != nil {
397404
r.makeError(ctx, w, http.StatusInternalServerError, "request creation: %s", err)
398405
return
399406
}
400407
if len(rangeHeader) > 0 {
401408
giphyReq.Header.Add("Range", rangeHeader)
402409
}
410+
giphyReq.Host = giphy.MediaHost
403411
resp, err := client.Do(giphyReq)
404412
if err != nil {
405413
r.makeError(ctx, w, resp.StatusCode, "failed to get read giphy link: %s", err)

0 commit comments

Comments
 (0)