MM-13838 Bypass the HTTP client when getting image dimensions from the image proxy (#10208)
* MM-13838 Bypass the HTTP client when getting image dimensions from the proxy * Add additional log messages to debug failing test * Fix unit test to work on Jenkins
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
85c60f1402
Коммит
dbf54b3599
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@@ -25,6 +26,23 @@ func (backend *AtmosCamoBackend) GetImage(w http.ResponseWriter, r *http.Request
|
||||
http.Redirect(w, r, backend.GetProxiedImageURL(imageURL), http.StatusFound)
|
||||
}
|
||||
|
||||
func (backend *AtmosCamoBackend) GetImageDirect(imageURL string) (io.ReadCloser, string, error) {
|
||||
req, err := http.NewRequest("GET", backend.GetProxiedImageURL(imageURL), nil)
|
||||
if err != nil {
|
||||
return nil, "", Error{err}
|
||||
}
|
||||
|
||||
client := backend.proxy.HTTPService.MakeClient(false)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, "", Error{err}
|
||||
}
|
||||
|
||||
// Note that we don't do any additional validation of the received data since we expect the image proxy to do that
|
||||
return resp.Body, resp.Header.Get("Content-Type"), nil
|
||||
}
|
||||
|
||||
func (backend *AtmosCamoBackend) GetProxiedImageURL(imageURL string) string {
|
||||
cfg := *backend.proxy.ConfigService.Config()
|
||||
siteURL := *cfg.ServiceSettings.SiteURL
|
||||
|
||||
Ссылка в новой задаче
Block a user