From 1c41b4af65541d7d67a1a0c09d69e7686de20432 Mon Sep 17 00:00:00 2001 From: Maxim Filonov <53992153+sl1depengwyn@users.noreply.github.com> Date: Wed, 22 Jul 2026 22:23:13 +0300 Subject: [PATCH] Add support for the RFC 10008 --- CHANGELOG.md | 5 +++++ Network/HTTP/Types.hs | 2 ++ Network/HTTP/Types/Header.hs | 7 +++++++ Network/HTTP/Types/Method.hs | 17 ++++++++++++++++- test/Network/HTTP/Types/HeaderSpec.hs | 1 + test/Network/HTTP/Types/MethodSpec.hs | 4 ++++ 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e216039..8093aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog for `http-types` +## 0.13 [unreleased] + +* Add support for the QUERY method and Accept-Query response field name from + [RFC 10008](https://www.rfc-editor.org/rfc/rfc10008.html). + ## 0.12.6 [unreleased] * Remove `array` dependency diff --git a/Network/HTTP/Types.hs b/Network/HTTP/Types.hs index e474b0d..1c48629 100644 --- a/Network/HTTP/Types.hs +++ b/Network/HTTP/Types.hs @@ -15,6 +15,7 @@ module Network.HTTP.Types ( methodConnect, methodOptions, methodPatch, + methodQuery, StdMethod (..), -- ** Parsing and redering methods @@ -160,6 +161,7 @@ module Network.HTTP.Types ( hAcceptCharset, hAcceptEncoding, hAcceptLanguage, + hAcceptQuery, hAcceptRanges, hAge, hAllow, diff --git a/Network/HTTP/Types/Header.hs b/Network/HTTP/Types/Header.hs index f2a5add..a7e95fa 100644 --- a/Network/HTTP/Types/Header.hs +++ b/Network/HTTP/Types/Header.hs @@ -23,6 +23,7 @@ module Network.HTTP.Types.Header ( hAcceptCharset, hAcceptEncoding, hAcceptLanguage, + hAcceptQuery, hAcceptRanges, hAge, hAllow, @@ -142,6 +143,12 @@ hAcceptEncoding = "Accept-Encoding" hAcceptLanguage :: HeaderName hAcceptLanguage = "Accept-Language" +-- | [Accept-Query](https://www.rfc-editor.org/rfc/rfc10008.html#section-3) +-- +-- @since 0.13 +hAcceptQuery :: HeaderName +hAcceptQuery = "Accept-Query" + -- | [Accept-Ranges](https://www.rfc-editor.org/rfc/rfc9110.html#name-accept-ranges) -- -- @since 0.9 diff --git a/Network/HTTP/Types/Method.hs b/Network/HTTP/Types/Method.hs index cecb06e..0fa8ab8 100644 --- a/Network/HTTP/Types/Method.hs +++ b/Network/HTTP/Types/Method.hs @@ -22,6 +22,7 @@ module Network.HTTP.Types.Method ( methodConnect, methodOptions, methodPatch, + methodQuery, -- ** Standard Methods @@ -89,8 +90,16 @@ methodOptions = renderStdMethod OPTIONS methodPatch :: Method methodPatch = renderStdMethod PATCH +-- | QUERY Method as defined in +-- . +-- +-- @since 0.13 +methodQuery :: Method +methodQuery = renderStdMethod QUERY + -- | HTTP standard method (as defined by RFC 2616, and PATCH which is defined --- by RFC 5789). +-- by RFC 5789, and QUERY which is defined by +-- ). -- -- @since 0.2.0 data StdMethod @@ -104,6 +113,11 @@ data StdMethod | OPTIONS | -- | @since 0.8.0 PATCH + | -- | QUERY as defined in + -- . + -- + -- @since 0.13 + QUERY deriving ( Read , Show @@ -154,3 +168,4 @@ renderStdMethod method = CONNECT -> "CONNECT" OPTIONS -> "OPTIONS" PATCH -> "PATCH" + QUERY -> "QUERY" diff --git a/test/Network/HTTP/Types/HeaderSpec.hs b/test/Network/HTTP/Types/HeaderSpec.hs index 86a290e..1f4f146 100644 --- a/test/Network/HTTP/Types/HeaderSpec.hs +++ b/test/Network/HTTP/Types/HeaderSpec.hs @@ -46,6 +46,7 @@ allHeaders = , (hAcceptCharset, "Accept-Charset") , (hAcceptEncoding, "Accept-Encoding") , (hAcceptLanguage, "Accept-Language") + , (hAcceptQuery, "Accept-Query") , (hAcceptRanges, "Accept-Ranges") , (hAge, "Age") , (hAllow, "Allow") diff --git a/test/Network/HTTP/Types/MethodSpec.hs b/test/Network/HTTP/Types/MethodSpec.hs index 53c1c0e..1eb4cd1 100644 --- a/test/Network/HTTP/Types/MethodSpec.hs +++ b/test/Network/HTTP/Types/MethodSpec.hs @@ -24,6 +24,7 @@ spec = do it "CONNECT" $ methodConnect `shouldBe` "CONNECT" it "OPTIONS" $ methodOptions `shouldBe` "OPTIONS" it "PATCH " $ methodPatch `shouldBe` "PATCH" + it "QUERY " $ methodQuery `shouldBe` "QUERY" it "StdMethod has all constants" $ let methodList = [ methodGet @@ -35,10 +36,13 @@ spec = do , methodConnect , methodOptions , methodPatch + , methodQuery ] in allMethods `shouldBe` methodList describe "parse/render method" $ do + it "parses QUERY as a standard method" $ + parseMethod methodQuery `shouldBe` Right QUERY it "round trips" $ do renderMethod . parseMethod <$> allMethods `shouldBe` allMethods it "also round trips for any ByteString" $