Skip to content

Commit 0f29124

Browse files
committed
fix: Remove GET/HEAD method request body handling
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.
1 parent 84377b3 commit 0f29124

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

internal/method/service.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,10 @@ func HandleDelete(w http.ResponseWriter, r *http.Request) {
4444
}
4545

4646
func HandleGet(w http.ResponseWriter, r *http.Request) {
47-
type RequestBody struct {
48-
ID string `json:"id"`
49-
}
5047
type ResponseBody struct {
5148
Status string `json:"status"`
5249
}
5350

54-
var requestBody RequestBody
55-
56-
body, err := io.ReadAll(r.Body)
57-
58-
if err != nil {
59-
utils.HandleError(w, err)
60-
return
61-
}
62-
63-
if err := json.Unmarshal(body, &requestBody); err != nil {
64-
utils.HandleError(w, err)
65-
return
66-
}
67-
6851
w.Header().Set("Content-Type", "application/json")
6952
w.WriteHeader(http.StatusOK)
7053

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

8164
func HandleHead(w http.ResponseWriter, r *http.Request) {
82-
type RequestBody struct {
83-
ID string `json:"id"`
84-
}
85-
86-
var requestBody RequestBody
87-
88-
body, err := io.ReadAll(r.Body)
89-
90-
if err != nil {
91-
utils.HandleError(w, err)
92-
return
93-
}
94-
95-
if err := json.Unmarshal(body, &requestBody); err != nil {
96-
utils.HandleError(w, err)
97-
return
98-
}
99-
10065
w.Header().Set("Content-Type", "application/json")
10166
w.WriteHeader(http.StatusOK)
10267
}

0 commit comments

Comments
 (0)