Only allow GET requests in the serve handler

This commit is contained in:
Melon 2025-03-29 23:48:22 +00:00
parent f3c05c46a8
commit 3719fc57cc
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 6 additions and 1 deletions

View File

@ -68,6 +68,11 @@ func cacheBuster(rw http.ResponseWriter, req *http.Request) {
}
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet {
http.Error(rw, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}
host, _, err := net.SplitHostPort(req.Host)
if err != nil {
host = req.Host

View File

@ -53,7 +53,7 @@ func serveTest(t *testing.T, address string, branch string, name string) {
//goland:noinspection HttpUrlsUsage
const httpPrefix = "http://"
req := httptest.NewRequest(http.MethodPost, httpPrefix+address, nil)
req := httptest.NewRequest(http.MethodGet, httpPrefix+address, nil)
if branch != "" {
req.AddCookie(&http.Cookie{
Name: "__bluebell-site-beta",