From c10354584de29c40fbc2b1eb8a22dda28cc3506b Mon Sep 17 00:00:00 2001 From: Umputun Date: Tue, 12 May 2020 22:26:45 -0500 Subject: [PATCH] dbl request limit size for count query for sites with a lot of posts on the page, the list of all urls can exceed the default 64k limit. I've see the request like this from news.radio-t.com --- backend/app/rest/api/rest_public.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/app/rest/api/rest_public.go b/backend/app/rest/api/rest_public.go index 103bb657..295a6a3e 100644 --- a/backend/app/rest/api/rest_public.go +++ b/backend/app/rest/api/rest_public.go @@ -356,9 +356,10 @@ func (s *public) countCtrl(w http.ResponseWriter, r *http.Request) { // POST /counts?site=siteID - get number of comments for posts from post body func (s *public) countMultiCtrl(w http.ResponseWriter, r *http.Request) { + const countBodyLimit int64 = 1024 * 128 // count request can be big for some site because it lists all urls siteID := r.URL.Query().Get("site") posts := []string{} - if err := render.DecodeJSON(http.MaxBytesReader(w, r.Body, hardBodyLimit), &posts); err != nil { + if err := render.DecodeJSON(http.MaxBytesReader(w, r.Body, countBodyLimit), &posts); err != nil { rest.SendErrorJSON(w, r, http.StatusBadRequest, err, "can't get list of posts from request", rest.ErrSiteNotFound) return }