Permalink
Browse files

Merge branch 'perf' of github.com:ztellman/aleph into perf

  • Loading branch information...
ztellman committed May 9, 2012
2 parents d4e2d29 + 32bbb59 commit 975c79a109f927bf1025acfaf8b6bbc6a5dde7d6
Showing with 13 additions and 13 deletions.
  1. +10 −10 src/aleph/http/core.clj
  2. +3 −3 test/aleph/test/http.clj
View
@@ -102,7 +102,7 @@
(defn normalize-headers [headers]
(zipmap
- (map
+ (map
#(->> (str/split (name %) #"-")
(map str/capitalize)
(str/join "-"))
@@ -145,19 +145,19 @@
;;;
-(defn decode-body [content-type character-encoding body]
+(defn decode-body [^String content-type ^String character-encoding body]
(when body
(let [charset (or character-encoding (options/charset))]
(cond
- (.startsWith ^String content-type "text/")
+ (.startsWith content-type "text/")
(formats/bytes->string body charset)
-
- (= content-type "application/json")
+
+ (.startsWith content-type "application/json")
(formats/decode-json body)
-
- (= content-type "application/xml")
+
+ (.startsWith content-type "application/xml")
(formats/decode-xml body)
-
+
:else
body))))
@@ -181,7 +181,7 @@
(write-callback))
(if (and honor-keep-alive? (not (:keep-alive? m)))
(close ch*)
- true))]
+ true))]
(if-not chunks
;; non-streaming response
@@ -309,7 +309,7 @@
:write-callback #(.close ^InputStream body)})
(instance? File body)
- (let [fc (.getChannel (RandomAccessFile. body "r"))
+ (let [fc (.getChannel (RandomAccessFile. ^File body "r"))
buf (-> fc
(.map FileChannel$MapMode/READ_ONLY 0 (.size fc))
ChannelBuffers/wrappedBuffer)]
View
@@ -99,7 +99,7 @@
(defn json-response-handler [ch request]
(enqueue ch
{:status 200
- :content-type "application/json"
+ :content-type "application/json; charset=UTF-8"
:body (formats/encode-json->string {:foo 1 :bar 2})}))
(defn error-aleph-handler [ch request]
@@ -248,10 +248,10 @@
(defn hello-world-handler [ch request]
(enqueue ch {:status 200, :body "hello"}))
-(deftest ^:benchmark run-http-benchmark
+(deftest ^:benchmark run-http-benchmark
(with-handler hello-world-handler
(let [create-conn #(deref (http-connection {:url "http://localhost:8080"}))]
-
+
(let [ch (create-conn)]
(bench "http hello-world"
(enqueue ch {:method :get})

0 comments on commit 975c79a

Please sign in to comment.