Skip to content

Instantly share code, notes, and snippets.

@sander
Last active August 8, 2016 13:58
Show Gist options
  • Save sander/34ca8b61c4a1a5c69a334050ec0951e2 to your computer and use it in GitHub Desktop.
Save sander/34ca8b61c4a1a5c69a334050ec0951e2 to your computer and use it in GitHub Desktop.
ring 1.6.0-beta4 issue
$ curl -vvv http://localhost:3000/
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 08 Aug 2016 13:50:07 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Server: Jetty(9.2.17.v20160517)
<
hello
* Connection #0 to host localhost left intact
$ lein run
2016-08-08 15:49:00.953:INFO::main: Logging initialized @1281ms
2016-08-08 15:49:01.043:INFO:oejs.Server:main: jetty-9.2.17.v20160517
2016-08-08 15:49:01.089:INFO:oejs.ServerConnector:main: Started ServerConnector@67f02555{HTTP/1.1}{0.0.0.0:3000}
2016-08-08 15:49:01.090:INFO:oejs.Server:main: Started @1417ms
Mon Aug 08 15:49:04 CEST 2016 {:ssl-client-cert nil, :protocol HTTP/1.1, :remote-addr 127.0.0.1, :headers {accept */*, host localhost:3000, user-agent curl/7.43.0}, :server-port 3000, :content-length nil, :content-type nil, :character-encoding nil, :uri /, :server-name localhost, :query-string nil, :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x4216c148 HttpInputOverHTTP@4216c148], :scheme :http, :request-method :get}
Mon Aug 08 15:49:34 CEST 2016 {:ssl-client-cert nil, :protocol HTTP/1.1, :remote-addr 127.0.0.1, :headers {accept */*, host localhost:3000, user-agent curl/7.43.0}, :server-port 3000, :content-length nil, :content-type nil, :character-encoding nil, :uri /, :server-name localhost, :query-string nil, :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x4216c148 HttpInputOverHTTP@4216c148], :scheme :http, :request-method :get}
Mon Aug 08 15:50:04 CEST 2016 {:ssl-client-cert nil, :protocol HTTP/1.1, :remote-addr 127.0.0.1, :headers {accept */*, host localhost:3000, user-agent curl/7.43.0}, :server-port 3000, :content-length nil, :content-type nil, :character-encoding nil, :uri /, :server-name localhost, :query-string nil, :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x4216c148 HttpInputOverHTTP@4216c148], :scheme :http, :request-method :get}
# Only the first request log is from an actual request made by curl.
# The other two seem to be copies of the first one.
(ns ringtest.core
(:require [clojure.java.io :as io]
[ring.core.protocols :as protocols]
[ring.adapter.jetty :as jetty])
(:import (java.util Date))
(:gen-class))
(defn async-body
[]
(reify protocols/StreamableResponseBody
(write-body-to-stream [_ _ out]
(with-open [w (io/writer out)]
(.write w "hello\n")
(.flush w)))))
(defn handler
[request respond raise]
(println (str (Date.)) request)
(respond
{:status 200
:headers {"Content-Type" "text/plain"}
:body (async-body)}))
(defn -main [& args]
(jetty/run-jetty #'handler {:port 3000 :async? true}))
(defproject ringtest "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[ring "1.6.0-beta4"]]
:main ringtest.core)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment