clojurehttp-kit

HTTP-Kit streaming and curl


I tried out the basic example for HTTP streaming of HTTP-Kit (http://www.http-kit.org/server.html#async), but if I curl to the endpoint I get all the messages at once, after the connection is closed (instead of getting them every 200ms, as it works in the browser). What's going on?

I also tried it like this:

    (schedule-task (* id 200) ;; send a message every 200ms
                   (send! channel
                          {:status 200
                           :headers {"Content-Type" "text/event-stream"
                                     "Connection" "keep-alive"}
                           :body (str "message from server #" id)}
                          false)) ; false => don't close after send

The behaviour is the same.


Solution

  • Seems to be an issue with curl and Streaming http. According to this post, the order of options is important

    Also, try using the -N, --no-buffer option