diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2020-04-02 23:51:31 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2020-04-02 23:51:31 +0100 |
| commit | 65a705b313911294a715519ee92e38db6cce330f (patch) | |
| tree | cfe75f6b9538a457a25986c8e2799a3fe8bf4a95 | |
| parent | feff62b8fcff9709dc6c7f0b56ce80a288367f29 (diff) | |
Reject non-GET requests
| -rw-r--r-- | cmd/gcp/main.go | 6 |
1 files changed, 6 insertions, 0 deletions
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" { |
