refine: the server-side http Request Body is always non-nil (#115908)

* refine: the server-side http Request Body is always non-nil

* revert changes under vendor

* Update staging/src/k8s.io/pod-security-admission/cmd/webhook/server/server.go

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>

* Update main.go

---------

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
This commit is contained in:
cc 2023-02-22 23:18:09 +08:00 committed by GitHub
parent 78c0018ca0
commit d49bff855f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -171,7 +171,7 @@ func (s *Server) HandleValidate(w http.ResponseWriter, r *http.Request) {
defer cancel() defer cancel()
} }
if r.Body == nil { if r.Body == nil || r.Body == http.NoBody {
err = errors.New("request body is empty") err = errors.New("request body is empty")
klog.ErrorS(err, "bad request") klog.ErrorS(err, "bad request")
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)

View File

@ -159,7 +159,7 @@ func handleRunRequest(w http.ResponseWriter, r *http.Request) {
} }
runner := urlParts[2] runner := urlParts[2]
if r.Body == nil { if r.Body == nil || r.Body == http.NoBody {
http.Error(w, "Missing request body", 400) http.Error(w, "Missing request body", 400)
return return
} }