From 65a705b313911294a715519ee92e38db6cce330f Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Thu, 2 Apr 2020 23:51:31 +0100 Subject: Reject non-GET requests --- cmd/gcp/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/gcp/main.go b/cmd/gcp/main.go index e8ad6ba..19823ba 100644 --- a/cmd/gcp/main.go +++ b/cmd/gcp/main.go @@ -14,6 +14,12 @@ import ( ) func redirect(resp http.ResponseWriter, req *http.Request) { + if req.Method != "GET" { + resp.Header()["Allow"] = []string{"GET"} + resp.WriteHeader(http.StatusMethodNotAllowed) + return + } + pkg := path.Join(req.Host, req.URL.Path) resp.Header()["Content-Type"] = []string{"text/html; charset=utf-8"} if v, ok := req.URL.Query()["go-get"]; ok && len(v) > 0 && v[0] == "1" { -- cgit v1.2.3-70-g09d2