Skip to content

Commit 0487992

Browse files
committed
Expand wrap-validation schema to allow string values for :request-method
1 parent eef3c66 commit 0487992

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGES.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Unreleased
2+
3+
* Loosen `wrap-validation` validation to support strings in :request-method. (See release in 0.6.2 for more information).
4+
15
### 0.7.1
26

37
* Bump Manifold to 0.4.2 to fix Promesa print-method hierarchy bug
@@ -34,11 +38,14 @@ Contributions by Matthew Davidson and Stefan van den Oord.
3438

3539
* Fix backwards-compatibility for transport options
3640
* Bump Netty to 4.1.89.Final, and io_uring to 0.0.18.Final
37-
* Add `wrap-validation` middleware to validate Ring maps
3841
* Bump deps and example deps
3942
* Upgrade CircleCI instance size
4043
* Switch to pedantic deps for CircleCI
4144

45+
### Breaking changes
46+
47+
* Add `wrap-validation` middleware to validate Ring maps [#679](https://github.com/clj-commons/aleph/pull/679). This adds a stricter interpretation of the ring spec, which may fail on previously valid input. For example, strings (e.g. `"GET"`) and keywords (e.g. `:get`) were both accepted values for `:request-method`, but now only keywords are accepted. This will be fixed in the release after 0.7.1.
48+
4249
Contributions by Arnaud Geiser, Ertuğrul Çetin, Jeroen van Dijk, David Ongaro,
4350
Matthew Davidson, and Moritz Heidkamp.
4451

src/aleph/http/schema.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(def uri [:maybe :string])
88
(def query-string [:maybe :string])
99
(def scheme [:enum :http :https])
10-
(def request-method :keyword)
10+
(def request-method [:or :string :keyword])
1111
(def content-type [:maybe [:or :string :keyword]])
1212
(def content-length [:maybe :int])
1313
(def character-encoding [:maybe :string])

test/aleph/http/client_middleware_test.clj

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@
183183
(doseq [req (mg/sample schema/ring-request)]
184184
(is (middleware/wrap-validation req)))
185185

186+
(testing "Request methods can be strings"
187+
(is (middleware/wrap-validation {:remote-addr "localhost"
188+
:server-name "computer"
189+
:scheme :http
190+
:request-method "GET"})))
191+
186192
(is (thrown-with-msg?
187193
IllegalArgumentException
188194
#"Invalid spec.*:in \[:request-method\].*:type :malli.core/missing-key"

0 commit comments

Comments
 (0)