POST in asynchronous mode not working yet?

78 views
Skip to first unread message

Hans Hübner

unread,
Dec 3, 2016, 8:23:02 AM12/3/16
to Ring
Hi,

I'm trying to use asynchronous mode (ring-1.6.0-beta6) for server sent events and GET requests work fine.  POST requests hang, however, and I don't know where to start looking what the problem is.  I can reproduce the issue with this code:

(defproject ring-async-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/core.async "0.2.395"]
                 [ring/ring "1.6.0-beta6"]
                 [compojure "1.6.0-beta1"]
                 [cheshire "5.6.3"]]
  :main ring-async-test.core)

(ns ring-async-test.core
  (:require [ring.adapter.jetty :as jetty]
            [ring.util.response :as response]
            [compojure.core :refer :all]
            [compojure.route :as route]))

(defn not-found []
  (fn [request respond raise]
    (respond (-> (response/response "Not found")
                 (response/status 404)))))

(defroutes app-routes
  (GET "/" [] "he")
  (not-found))

(defn app []
  (-> app-routes))

(defonce server (atom nil))

(defn start-server []
  (when @server
    (.stop @server))
  (reset! server (jetty/run-jetty (app)
                                  {:port 3803
                                   :join? false
                                   :async? true})))

Any POST request I send to this server just hangs:

paracetamol 1162_% curl -dxx -vv http://localhost:3803/x
*   Trying ::1...
* Connected to localhost (::1) port 3803 (#0)
> POST /x HTTP/1.1
> Host: localhost:3803
> User-Agent: curl/7.49.1
> Accept: */*
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 2 out of 2 bytes
^C

Is there something wrong with my code, or are POST requests not supported in async mode yet?

Thanks!
Hans

James Reeves

unread,
Dec 3, 2016, 8:39:55 AM12/3/16
to Ring
Looks like you've hit a bug. I'm currently investigating.

- James

--
You received this message because you are subscribed to the Google Groups "Ring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Reeves

unread,
Dec 3, 2016, 9:57:24 AM12/3/16
to Ring
It turned out to be a bug in Compojure. A missing "respond" meant that the routes would hang if there was a method mismatch.

I added a test, fixed the bug and released Compojure 1.6.0-beta2. If you upgrade to that, it should fix your problem.

- James
Reply all
Reply to author
Forward
0 new messages