Apply MAX_MESSAGE_SIZE to the whole request body (closes #250)
check / check (push) Canceled after 0s

Creating a session, logging in and posting a message stopped reading
after the first JSON value, so the limit never saw the rest of the
body and trailing bytes were ignored. All three now read the whole
limited body and decode it with json.Unmarshal. A body over the limit,
or anything but whitespace after the value, gets 400 invalid request
body.

Model: opus-5-5
This commit is contained in:
2026-11-03 07:47:35 +00:00
parent 4221f71920
commit 755e9ce6fa
4 changed files with 117 additions and 4 deletions
+2 -2
View File
@@ -188,7 +188,7 @@ func (hdlr *Handlers) handleCreateSession(
var payload createRequest
err := json.NewDecoder(request.Body).Decode(&payload)
err := decodeJSON(request, &payload)
if err != nil {
hdlr.respondError(
writer, request,
@@ -925,7 +925,7 @@ func (hdlr *Handlers) HandleSendCommand() http.HandlerFunc {
var payload commandRequest
err := json.NewDecoder(request.Body).Decode(&payload)
err := decodeJSON(request, &payload)
if err != nil {
hdlr.respondError(
writer, request,