Skip to content

Commit

Permalink
Confirm SSEs are UTF-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Feb 10, 2015
1 parent b84d8ec commit 5ce4001
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion web/test/immutant/web/sse_test.clj
Expand Up @@ -14,7 +14,7 @@

(ns immutant.web.sse-test
(:require [clojure.test :refer :all]
[testing.web :refer (event-source handle-events)]
[testing.web :refer (event-source handle-events get-response)]
[immutant.web.sse :refer :all]
[immutant.web :refer (run stop)]
[clojure.string :refer (split-lines)]))
Expand Down Expand Up @@ -61,3 +61,14 @@
(is (= ["5" "4" "3" "2" "1"] (take 5 @result)))
(is (= #{:done "bye!"} (set (drop 5 @result))))
(stop server)))

(deftest sse-encoding-should-be-utf8
(let [app (fn [req]
(as-channel req
:on-open (fn [ch] (send! ch "foo" {:close? true}))))
server (run app)
body-stream (:raw-body (get-response "http://localhost:8080"))]
(is body-stream)
(is (= "data:foo\n\n"
(String. (.toByteArray body-stream) "UTF-8")))
(stop server)))

0 comments on commit 5ce4001

Please sign in to comment.