Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix for github issue #2.

  • Loading branch information...
commit ae8b018815d7ecb0fccaf54821269a57dd483471 1 parent 585d915
Tim McIver authored

Showing 2 changed files with 10 additions and 2 deletions. Show diff stats Hide diff stats

  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."
110 110 (let [post-fn (get-in resource [:methods :post])]
111 111 (post-fn request)
112 112 (let [redirect-uri (:redirect-after-html-post resource)]
113   - (if (and redirect-uri
114   - (#{"text/html" "application/xhtml+xml"} (util/optimal-media-type request resource)))
  113 + (if (and redirect-uri (util/accepts-html? request))
115 114 (ring/redirect-after-post redirect-uri)
116 115 (response/code 200)))))
9 src/hottop/util.clj
@@ -45,6 +45,15 @@
45 45 (interpose ", ")
46 46 (apply str)))
47 47
  48 +(defn accepts-html?
  49 + "Returns truthy if the request indicates that it will accept a response in
  50 +HTML format (the Accept header contains one or both of 'text/html' or
  51 +'application/xhtml+xml'), falsey otherwise."
  52 + [request]
  53 + (when-let [{{accept-str "accept"} :headers} request]
  54 + (let [accept-types (map :type (parse-accept-header accept-str))]
  55 + (some #{"text/html" "application/xhtml+xml"} accept-types))))
  56 +
48 57 (defn ^{:webmachine-node :c4} optimal-media-type
49 58 "Returns a string representing the optimal client-requested media type or nil
50 59 if there isn't one. See RFC 2046 (http://tools.ietf.org/html/rfc2046) or

0 comments on commit ae8b018

Please sign in to comment.
Something went wrong with that request. Please try again.