From 9f08f0757469017edb0165f70791694667edb08b Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 6 Sep 2011 22:31:29 -0700 Subject: [PATCH] Fix 404 handler MIME Content-Type header. The returned content type had a - rather than /, which wasn't strictly legal, albeit probably not notable what with the defaulting to plain text and all. Also, add tests to ensure that we don't regress on the failure. Signed-off-by: Daniel Pittman --- src/clothesline/request_handler.clj | 2 +- test/clothesline/test/request_handler.clj | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/clothesline/test/request_handler.clj diff --git a/src/clothesline/request_handler.clj b/src/clothesline/request_handler.clj index 8dab670..faaca7f 100644 --- a/src/clothesline/request_handler.clj +++ b/src/clothesline/request_handler.clj @@ -20,7 +20,7 @@ (defn no-handler-found [req] "Returns a 404 when no appropriate handler was found" (-> (response "404 - Resource Not found") - (content-type "text-plain") + (content-type "text/plain") (status 404))) (defn- match-route [req route handler] diff --git a/test/clothesline/test/request_handler.clj b/test/clothesline/test/request_handler.clj new file mode 100644 index 0000000..6e6ce16 --- /dev/null +++ b/test/clothesline/test/request_handler.clj @@ -0,0 +1,10 @@ +(ns clothesline.test.request-handler + (:use clojure.test) + (:require [clothesline.request-handler :as rh] + [clothesline.test.test-helpers :as test])) + +(deftest no-handler-found + (let [response (rh/no-handler-found (test/make-request))] + (is (= 404 (:status response))) + ;; this was broken, so enforce a legal content-type. + (is (re-find #"^[^/]+/[^/]+$" (get-in response [:headers "Content-Type"])))))