Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for github issue #2.

  • Loading branch information...
commit ae8b018815d7ecb0fccaf54821269a57dd483471 1 parent 585d915
@tmciver authored
Showing with 10 additions and 2 deletions.
  1. +1 −2  src/hottop/proc.clj
  2. +9 −0 src/hottop/util.clj
3  src/hottop/proc.clj
@@ -110,7 +110,6 @@ web browser."
(let [post-fn (get-in resource [:methods :post])]
(post-fn request)
(let [redirect-uri (:redirect-after-html-post resource)]
- (if (and redirect-uri
- (#{"text/html" "application/xhtml+xml"} (util/optimal-media-type request resource)))
+ (if (and redirect-uri (util/accepts-html? request))
(ring/redirect-after-post redirect-uri)
(response/code 200)))))
9 src/hottop/util.clj
@@ -45,6 +45,15 @@
(interpose ", ")
(apply str)))
+(defn accepts-html?
+ "Returns truthy if the request indicates that it will accept a response in
+HTML format (the Accept header contains one or both of 'text/html' or
+'application/xhtml+xml'), falsey otherwise."
+ [request]
+ (when-let [{{accept-str "accept"} :headers} request]
+ (let [accept-types (map :type (parse-accept-header accept-str))]
+ (some #{"text/html" "application/xhtml+xml"} accept-types))))
(defn ^{:webmachine-node :c4} optimal-media-type
"Returns a string representing the optimal client-requested media type or nil
if there isn't one. See RFC 2046 ( or
Please sign in to comment.
Something went wrong with that request. Please try again.