small improvements)

This commit is contained in:
Laptop
2025-06-12 17:31:25 +03:00
parent d2117e5182
commit 3d96470a05
8 changed files with 87 additions and 110 deletions

View File

@@ -11,6 +11,7 @@ import (
)
var al_httpc *fasthttp.HostClient
var sndcdn = []byte(".sndcdn.com")
func Load(r *fiber.App) {
@@ -36,7 +37,7 @@ func Load(r *fiber.App) {
return err
}
if !bytes.HasSuffix(parsed.Host(), []byte(".sndcdn.com")) {
if !bytes.HasSuffix(parsed.Host(), sndcdn) {
return fiber.ErrBadRequest
}
@@ -63,12 +64,12 @@ func Load(r *fiber.App) {
return err
}
c.Response().Header.SetContentType("image/jpeg")
c.Response().Header.SetContentTypeBytes(resp.Header.ContentType())
c.Set("Cache-Control", cfg.ImageCacheControl)
//return c.Send(resp.Body())
pr := misc.AcquireProxyReader()
pr.Reader = resp.BodyStream()
pr.Resp = resp
return c.SendStream(pr)
return c.SendStream(pr, resp.Header.ContentLength())
})
}