Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistency with servlet implementation #8

Open
mtkp opened this issue May 16, 2019 · 1 comment
Open

Consistency with servlet implementation #8

mtkp opened this issue May 16, 2019 · 1 comment

Comments

@mtkp
Copy link

mtkp commented May 16, 2019

Seems like there is an inconsistency between the :ring/request spec and the servlet implementation, in particular the map created by build-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 a string? and the implementation returns the :query-string key always but sometimes a null (nil) value via the .getQueryString method.

@mtkp
Copy link
Author

mtkp commented May 16, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant