packages feed

wai-handler-hal 0.4.0.1 → 0.4.0.2

raw patch · 5 files changed

+59/−7 lines, 5 filesnew-uploader

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for wai-handler-hal +## 0.4.0.2 -- 2025-08-14++- Union single and multi-value query parameters and headers when+  converting a `hal` `ProxyRequest` to a `wai` `Request`+ ## 0.4.0.1 -- 2025-02-19  - Use a `NonEmpty` list when consuming the result of `getAddrInfo`.
src/Network/Wai/Handler/Hal.hs view
@@ -216,6 +216,15 @@ -- | Convert the request sent to a Lambda serving an API Gateway proxy -- integration into a WAI request. --+-- When processing multiple values for the same+-- [HTTP header|query parameter], API Gateway will put the final such+-- value into ['HalRequest.headers'|'HalRequest.queryStringParameters']+-- and all such values into+-- ['HalRequest.multiValueHeaders'|'HalRequest.multiValueQueryStringParameters'].+-- We merge both but exclusively use the multi-value version if it exists,+-- to ensure that [headers|query parameters] defined in hand-crafted+-- 'HalRequest.ProxyRequest's always appear in the 'WaiRequest.Request'.+-- -- __Note:__ We aren't told the HTTP version the client is using, so -- we assume HTTP 1.1. toWaiRequest ::@@ -227,7 +236,9 @@       pathSegments =         Text.splitOn "/" . Text.dropWhile (== '/') $ HalRequest.path req       query =-        sort . constructQuery $ HalRequest.multiValueQueryStringParameters req+        sort . constructQuery $+          HalRequest.multiValueQueryStringParameters req+            `HashMap.union` ((: []) <$> HalRequest.queryStringParameters req)       hints =         NS.defaultHints           { NS.addrFlags = [NS.AI_NUMERICHOST],@@ -275,7 +286,8 @@                     (CI.map Text.encodeUtf8 hName, Text.encodeUtf8 hValue)               )             . HashMap.toList-            $ HalRequest.multiValueHeaders req,+            $ HalRequest.multiValueHeaders req+              `HashMap.union` ((: []) <$> HalRequest.headers req),         Wai.isSecure = True,         Wai.remoteHost = sourceHost,         Wai.pathInfo = pathSegments,
test/data/ProxyRequest.json view
@@ -9,12 +9,17 @@         "X-Amzn-Trace-Id": "Root=1-11111111-111111111111111111111111",         "X-Forwarded-For": "123.123.123.123",         "X-Forwarded-Port": "443",-        "X-Forwarded-Proto": "https"+        "X-Forwarded-Proto": "https",+        "Content-Type": "application/json"     },     "multiValueHeaders": {         "accept": [             "application/json"         ],+        "Accept-Language": [+            "en",+            "fr"+        ],         "Host": [             "ffffffffff.execute-api.us-east-1.amazonaws.com"         ],@@ -37,7 +42,8 @@     "queryStringParameters": {         "MaxResultsPerPage": "100",         "PostedAfter": "2022-05-31T22:16:43Z",-        "PostedBefore": "2022-05-31T23:16:43Z"+        "PostedBefore": "2022-05-31T23:16:43Z",+        "language": "en"     },     "multiValueQueryStringParameters": {         "MaxResultsPerPage": [@@ -48,6 +54,10 @@         ],         "PostedBefore": [             "2022-05-31T23:16:43Z"+        ],+        "country_code": [+            "US",+            "CA"         ]     },     "pathParameters": {
test/golden/WaiRequest.txt view
@@ -2,13 +2,25 @@     { requestMethod = "GET"     , httpVersion = HTTP/1.1     , rawPathInfo = "/foo/bar/baz"-    , rawQueryString = "?MaxResultsPerPage=100&PostedAfter=2022-05-31T22%3A16%3A43Z&PostedBefore=2022-05-31T23%3A16%3A43Z"+    , rawQueryString = "?MaxResultsPerPage=100&PostedAfter=2022-05-31T22%3A16%3A43Z&PostedBefore=2022-05-31T23%3A16%3A43Z&country_code=CA&country_code=US&language=en"     , requestHeaders =         [             ( "accept"             , "application/json"             )         ,+            ( "Accept-Language"+            , "en"+            )+        ,+            ( "Accept-Language"+            , "fr"+            )+        ,+            ( "Content-Type"+            , "application/json"+            )+        ,             ( "Host"             , "ffffffffff.execute-api.us-east-1.amazonaws.com"             )@@ -52,6 +64,18 @@         ,             ( "PostedBefore"             , Just "2022-05-31T23:16:43Z"+            )+        ,+            ( "country_code"+            , Just "CA"+            )+        ,+            ( "country_code"+            , Just "US"+            )+        ,+            ( "language"+            , Just "en"             )         ]     , requestBody = <IO ByteString>
wai-handler-hal.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               wai-handler-hal-version:            0.4.0.1+version:            0.4.0.2 synopsis:           Wrap WAI applications to run on AWS Lambda description:   This library provides a function 'Network.Wai.Handler.Hal.run' to@@ -37,6 +37,7 @@    || ==9.6.6    || ==9.8.2    || ==9.10.1+   || ==9.12.1  common opts   default-language: Haskell2010@@ -49,7 +50,7 @@  common deps   build-depends:-    , base                  >=4.12      && <4.21+    , base                  >=4.12      && <4.22     , base64-bytestring     >=1.0.0.0   && <1.3     , bytestring            >=0.10.8    && <0.13     , case-insensitive      ^>=1.2.0.0