diff --git a/httpbin/handlers.go b/httpbin/handlers.go index 58f0579d43f19c3e4bf95db95df145b1193647a9..701211c17c31225c1d967cf5c4452ac24aa11ded 100644 --- a/httpbin/handlers.go +++ b/httpbin/handlers.go @@ -23,10 +23,6 @@ var acceptedMediaTypes = []string{ "image/", } -func notImplementedHandler(w http.ResponseWriter, r *http.Request) { - http.Error(w, "Not implemented", http.StatusNotImplemented) -} - // Index renders an HTML index page func (h *HTTPBin) Index(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { @@ -597,18 +593,6 @@ func (h *HTTPBin) Cache(w http.ResponseWriter, r *http.Request) { return } - // Did we get an additional /cache/N path parameter? If so, validate it - // and set the Cache-Control header. - parts := strings.Split(r.URL.Path, "/") - if len(parts) == 3 { - seconds, err := strconv.ParseInt(parts[2], 10, 64) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - w.Header().Add("Cache-Control", fmt.Sprintf("public, max-age=%d", seconds)) - } - lastModified := time.Now().Format(time.RFC1123) w.Header().Add("Last-Modified", lastModified) w.Header().Add("ETag", sha1hash(lastModified)) diff --git a/httpbin/handlers_test.go b/httpbin/handlers_test.go index 46cb62f664ccd127896c2ebef5d1b64456940a06..73a450f10cf2f91b1036fc330aeddd59b3c9a95d 100644 --- a/httpbin/handlers_test.go +++ b/httpbin/handlers_test.go @@ -1720,7 +1720,7 @@ func TestCacheControl(t *testing.T) { {"/cache/3.14", http.StatusBadRequest}, } for _, test := range badTests { - t.Run(fmt.Sprintf("bad/%s", test.url), func(t *testing.T) { + t.Run("bad"+test.url, func(t *testing.T) { r, _ := http.NewRequest("GET", test.url, nil) w := httptest.NewRecorder() handler.ServeHTTP(w, r) @@ -1945,6 +1945,8 @@ func TestLinks(t *testing.T) { url string expectedStatus int }{ + {"/links/10/1/foo", http.StatusNotFound}, + // invalid N {"/links/3.14", http.StatusBadRequest}, {"/links/-1", http.StatusBadRequest},