소스 검색

control: fix body rejection guard for empty POST requests

rejectBody() returns true when the request body is acceptable and false when a body must be rejected. The TX and fault-reset handlers treated the return value the wrong way around and returned early on valid empty POST requests. This prevented actions like /tx/stop from running in the normal no-body case.

Update the handlers to only abort when rejectBody() reports an actual rejection, so empty POST control actions proceed as intended.
main
Jan 4 달 전
부모
커밋
1d683d1d8f
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. +5
    -2
      internal/control/control.go

+ 5
- 2
internal/control/control.go 파일 보기

@@ -155,12 +155,15 @@ func hasRequestBody(r *http.Request) bool {
}

func (s *Server) rejectBody(w http.ResponseWriter, r *http.Request) bool {
// Returns true when the request has an unexpected body and the error response
// has already been written — callers should return immediately in that case.
// Returns false when there is no body (happy path — request should proceed).
if !hasRequestBody(r) {
return true
return false
}
s.recordAudit(auditUnexpectedBody)
http.Error(w, noBodyErrMsg, http.StatusBadRequest)
return false
return true
}

func (s *Server) recordAudit(evt auditEvent) {


불러오는 중...
취소
저장