Skip to content

Commit

Permalink
Disable chunked transfer encoding (#3895)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz authored Jun 24, 2024
1 parent a73ed64 commit b1959cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/handlers/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func GetPagination(qs url.Values, defaultLimit, maxLimit int) (*hub.Pagination,
// response writer, setting the appropriate content type, cache and status code.
func RenderJSON(w http.ResponseWriter, dataJSON []byte, cacheMaxAge time.Duration, code int) {
w.Header().Set("Cache-Control", BuildCacheControlHeader(cacheMaxAge))
w.Header().Set("Content-Length", strconv.Itoa(len(dataJSON)))
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
_, _ = w.Write(dataJSON)
Expand Down
3 changes: 2 additions & 1 deletion internal/handlers/pkg/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ func (h *Handlers) GetChartValues(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
return
}
w.Header().Set("Content-Type", "application/yaml")
w.Header().Set("Cache-Control", helpers.BuildCacheControlHeader(24*time.Hour))
w.Header().Set("Content-Length", strconv.Itoa(len(data)))
w.Header().Set("Content-Type", "application/yaml")
_, _ = w.Write(data)
}

Expand Down
2 changes: 2 additions & 0 deletions internal/handlers/static/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"os"
"path"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -116,6 +117,7 @@ func (h *Handlers) Image(w http.ResponseWriter, r *http.Request) {

// Set headers and write image data to response writer
w.Header().Set("Cache-Control", helpers.BuildCacheControlHeader(StaticCacheMaxAge))
w.Header().Set("Content-Length", strconv.Itoa(len(data)))
if svg.Is(data) {
w.Header().Set("Content-Type", "image/svg+xml")
} else {
Expand Down

0 comments on commit b1959cd

Please sign in to comment.