Open mtkp opened 5 years ago
Repro:
;; deps.edn
{:deps {org.clojure/spec.alpha {:mvn/version "0.2.176"}
ring/ring-jetty-adapter {:mvn/version "1.7.1"}
ring/ring-spec {:mvn/version "0.0.4"}}}
;; src/main.clj
(ns main
(:require
[clojure.spec.alpha :as s]
[ring.adapter.jetty :as jetty]
[ring.core.spec]))
(defn handler [request]
(when-not (s/valid? :ring/request request)
(s/explain :ring/request request)
(flush))
{:status 200 :body "ok"})
(defn -main [& args]
(jetty/run-jetty handler {:port 34567}))
clj -m main
curl localhost:34567
Seems like there is an inconsistency between the
:ring/request
spec and the servlet implementation, in particular the map created bybuild-request-map
. This is based on my assumption that the request handed to my handler from ring jetty server, for example, should satisfy the:ring/request
spec.The spec says the
:query-string
key is optional but the value must be astring?
and the implementation returns the:query-string
key always but sometimes a null (nil
) value via the [.getQueryString
](https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getQueryString()) method.