   ;;       all downstream function calls happen on the same
   ;;       thread.
   (when (.chunked? current-state)
-    ((.downstream current-state) (.upstream current-state) :connected nil)))
+    ((.upstream current-state) (.downstream current-state) :connected nil)))
 
 (defn- handle-ch-interest-change
   [state current-state writable?]
-  (let [downstream-fn (.downstream current-state)
-        upstream-fn   (.upstream current-state)
+  (let [upstream-fn   (.upstream current-state)
+        downstream-fn (.downstream current-state)
         ch            (.ch current-state)]
-    (when (and downstream-fn (not= (.isWritable ch) @writable?))
+    (when (and upstream-fn (not= (.isWritable ch) @writable?))
       (swap-then!
        writable? not
-       #(try (downstream-fn upstream-fn (if % :resume :pause) nil)
+       #(try (upstream-fn downstream-fn (if % :resume :pause) nil)
              (catch Exception err
                (throw (Exception. "Not implemented yet"))))))))
 


(defn- stream-or-finalize-response
  [state ^HttpChunk msg args]
  (let [downstream-fn (.downstream args)
        upstream-fn   (.upstream args)]
    (if (.isLast msg)
      (do (swap-then!
           state
           (fn [current-state]
             (if (= response-pending (.next-up-fn current-state))
               (assoc current-state
                 :next-up-fn request-complete
                 :next-dn-fn nil)
               (assoc current-state
                 :next-dn-fn nil)))
           finalize-request)
          (downstream-fn upstream-fn :done nil))
      (downstream-fn upstream-fn :body (.getContent msg)))))

(defn- initial-response
  [state ^HttpResponse msg current-state]

   state
   (fn [current-state]
     (assoc current-state
       :next-dn-fn request-complete
       :aborted?   true))
   (fn [current-state]
     (when (.upstream current-state)
       (try
         ((.upstream current-state) (.downstream current-state) :abort err)
         (catch Exception ex
           (.printStackTrace ex)))
       (finalize-request current-state)))))
