Skip to content

Update schema to accept string HTTP methods like "GET", as well as keywords. #685

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

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Unreleased

* Loosen `wrap-validation` validation to support strings in :request-method. (See release in 0.6.2 for more information).

### 0.8.3

* Bump Netty to 4.1.118.Final (CVE-2025-24970 and bug-fixes)
Expand Down Expand Up @@ -46,7 +50,7 @@ Manifold contributions by Jacob Maine and Ferdinand Beyer
* Bump Manifold to 0.4.2 to fix Promesa print-method hierarchy bug
* Bump Dirigiste to 1.0.4
* Log SSL handshake completion at debug level instead of info level

Contributions by Matthew Davidson and Eric Dvorsak

### 0.7.0
Expand Down Expand Up @@ -77,11 +81,14 @@ Contributions by Matthew Davidson and Stefan van den Oord.

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

### Breaking changes

* Add `wrap-validation` middleware to validate Ring maps [#679](https://github.com/clj-commons/aleph/pull/679). While the Ring spec has always [required](https://github.com/ring-clojure/ring/blob/master/SPEC.md#request-method) a keyword value for `:request-method` (e.g. `:get`), previously, Aleph would also accept string methods (e.g. `"GET"`). This means that `wrap-validation` may cause HTTP requests to fail on previously valid input. This will be fixed in the release after 0.8.3.

Contributions by Arnaud Geiser, Ertuğrul Çetin, Jeroen van Dijk, David Ongaro,
Matthew Davidson, and Moritz Heidkamp.

Expand Down
2 changes: 1 addition & 1 deletion src/aleph/http/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(def uri [:maybe :string])
(def query-string [:maybe :string])
(def scheme [:enum :http :https])
(def request-method :keyword)
(def request-method [:or :string :keyword])
(def content-type [:maybe [:or :string :keyword]])
(def content-length [:maybe :int])
(def character-encoding [:maybe :string])
Expand Down
8 changes: 7 additions & 1 deletion test/aleph/http/client_middleware_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require
[aleph.http.client-middleware :as middleware]
[aleph.http.schema :as schema]
[clojure.test :as t :refer [deftest is]]
[clojure.test :as t :refer [deftest is testing]]
[malli.core :as m]
[malli.generator :as mg])
(:import
Expand Down Expand Up @@ -183,6 +183,12 @@
(doseq [req (mg/sample schema/ring-request)]
(is (middleware/wrap-validation req)))

(testing "Request methods can be strings"
(is (middleware/wrap-validation {:remote-addr "localhost"
:server-name "computer"
:scheme :http
:request-method "GET"})))

(is (thrown-with-msg?
IllegalArgumentException
#"Invalid spec.*:in \[:request-method\].*:type :malli.core/missing-key"
Expand Down