fix: Fix requests for overloaded functions from html forms to no longer hang
Fixes #1846
This commit is contained in:
committed by
Wolfgang Walther
parent
082c91c855
commit
b4ca70708a
@@ -243,9 +243,9 @@ userApiRequest conf@AppConfig{..} dbStructure req reqBody
|
||||
parsedColumns = pRequestColumns columns
|
||||
payloadColumns =
|
||||
case (contentType, action) of
|
||||
(_, ActionInvoke InvGet) -> S.fromList $ fst <$> rpcQParams
|
||||
(_, ActionInvoke InvHead) -> S.fromList $ fst <$> rpcQParams
|
||||
(CTOther "application/x-www-form-urlencoded", _) -> S.fromList $ map (toS . fst) $ parseSimpleQuery $ toS reqBody
|
||||
(_, ActionInvoke InvGet) -> S.fromList $ fst <$> rpcQParams
|
||||
(_, ActionInvoke InvHead) -> S.fromList $ fst <$> rpcQParams
|
||||
(CTUrlEncoded, _) -> S.fromList $ map (toS . fst) $ parseSimpleQuery $ toS reqBody
|
||||
_ -> case (relevantPayload, fromRight Nothing parsedColumns) of
|
||||
(Just ProcessedJSON{pjKeys}, _) -> pjKeys
|
||||
(Just RawJSON{}, Just cls) -> cls
|
||||
|
||||
@@ -659,6 +659,34 @@ spec actualPgVersion =
|
||||
it "overloaded(text, text, text)" $
|
||||
get "/rpc/overloaded?a=1&b=2&c=3" `shouldRespondWith` [json|"123"|]
|
||||
|
||||
it "overloaded_html_form()" $
|
||||
request methodPost "/rpc/overloaded_html_form"
|
||||
[("Content-Type", "application/x-www-form-urlencoded")]
|
||||
""
|
||||
`shouldRespondWith`
|
||||
[json|[1,2,3]|]
|
||||
|
||||
it "overloaded_html_form(json) single-object" $
|
||||
request methodPost "/rpc/overloaded_html_form"
|
||||
[("Content-Type", "application/x-www-form-urlencoded"), ("Prefer","params=single-object")]
|
||||
"a=1&b=2&c=3"
|
||||
`shouldRespondWith`
|
||||
[json|{"a": "1", "b": "2", "c": "3"}|]
|
||||
|
||||
it "overloaded_html_form(int, int)" $
|
||||
request methodPost "/rpc/overloaded_html_form"
|
||||
[("Content-Type", "application/x-www-form-urlencoded")]
|
||||
"a=1&b=2"
|
||||
`shouldRespondWith`
|
||||
[str|3|]
|
||||
|
||||
it "overloaded_html_form(text, text, text)" $
|
||||
request methodPost "/rpc/overloaded_html_form"
|
||||
[("Content-Type", "application/x-www-form-urlencoded")]
|
||||
"a=1&b=2&c=3"
|
||||
`shouldRespondWith`
|
||||
[json|"123"|]
|
||||
|
||||
context "only for POST rpc" $ do
|
||||
it "gives a parse filter error if GET style proc args are specified" $
|
||||
post "/rpc/sayhello?name=John" [json|{}|] `shouldRespondWith` 400
|
||||
|
||||
Vendored
+16
@@ -1267,6 +1267,22 @@ create or replace function test.overloaded(a text, b text, c text) returns text
|
||||
select a || b || c
|
||||
$$ language sql;
|
||||
|
||||
create or replace function test.overloaded_html_form() returns setof int as $$
|
||||
values (1), (2), (3);
|
||||
$$ language sql;
|
||||
|
||||
create or replace function test.overloaded_html_form(single_param json) returns json as $$
|
||||
select single_param;
|
||||
$$ language sql;
|
||||
|
||||
create or replace function test.overloaded_html_form(a int, b int) returns int as $$
|
||||
select a + b
|
||||
$$ language sql;
|
||||
|
||||
create or replace function test.overloaded_html_form(a text, b text, c text) returns text as $$
|
||||
select a || b || c
|
||||
$$ language sql;
|
||||
|
||||
create table test.leak(
|
||||
id serial primary key,
|
||||
blob bytea
|
||||
|
||||
Reference in New Issue
Block a user