       (startAsync [] (async-context (request :completed))))))
 
 (defn- servlet-response [response]
-  (proxy [javax.servlet.http.HttpServletResponse] []
-    (getOutputStream []
-      (proxy [javax.servlet.ServletOutputStream] []
-        (write [body & _]
-          (swap! response assoc :body body))))
-    (setStatus [status]
-      (swap! response assoc :status status))
-    (setHeader [name value]
-      (swap! response assoc-in [:headers name] value))
-    (setCharacterEncoding [value])
-    (setContentType [value]
-      (swap! response assoc :content-type value))))
+  (let [output-stream (java.io.ByteArrayOutputStream.)]
+    (swap! response assoc :body output-stream)
+    (proxy [javax.servlet.http.HttpServletResponse] []
+      (getOutputStream []
+        (proxy [javax.servlet.ServletOutputStream] []
+          (write
+            ([b] (.write output-stream b))
+            ([b off len] (.write output-stream b off len)))))
+      (setStatus [status]
+        (swap! response assoc :status status))
+      (setHeader [name value]
+        (swap! response assoc-in [:headers name] value))
+      (setCharacterEncoding [value])
+      (setContentType [value]
+        (swap! response assoc :content-type value)))))
 
 (defn- servlet-config []
   (proxy [javax.servlet.ServletConfig] []

        (is (= (@response :status) 200))
        (is (= (@response :content-type) "text/plain"))
        (is (= (get-in @response [:headers "X-Server"]) "Bar"))
        (is (= (take-while (complement zero?) (@response :body))
               (seq (.getBytes "Hello World"))))))))

(deftest servlet-cps-test
  (let [handler  (fn [_ respond _]

    (is (= @(:completed request) true))
    (is (= (@response :status) 200))
    (is (= (@response :content-type) "text/plain"))
    (is (= (.toString (@response :body)) "Hello World"))))

(defservice "foo-"
  (fn [_]
