Skip to content

Commit

Permalink
fix: Remove GET/HEAD method request body handling
Browse files Browse the repository at this point in the history
Reference: whatwg/fetch#551

Certain interpretations and implementations of the IETF RFC do not support GET/HEAD HTTP method request body content. The request body checking is extraneous for the purpose of this testing, which is only intended for just the HTTP methods themselves, so just removing it.
  • Loading branch information
bflad committed Sep 4, 2024
1 parent 84377b3 commit 0f29124
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions internal/method/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,10 @@ func HandleDelete(w http.ResponseWriter, r *http.Request) {
}

func HandleGet(w http.ResponseWriter, r *http.Request) {
type RequestBody struct {
ID string `json:"id"`
}
type ResponseBody struct {
Status string `json:"status"`
}

var requestBody RequestBody

body, err := io.ReadAll(r.Body)

if err != nil {
utils.HandleError(w, err)
return
}

if err := json.Unmarshal(body, &requestBody); err != nil {
utils.HandleError(w, err)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)

Expand All @@ -79,24 +62,6 @@ func HandleGet(w http.ResponseWriter, r *http.Request) {
}

func HandleHead(w http.ResponseWriter, r *http.Request) {
type RequestBody struct {
ID string `json:"id"`
}

var requestBody RequestBody

body, err := io.ReadAll(r.Body)

if err != nil {
utils.HandleError(w, err)
return
}

if err := json.Unmarshal(body, &requestBody); err != nil {
utils.HandleError(w, err)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
}
Expand Down

0 comments on commit 0f29124

Please sign in to comment.