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
@@ -245,7 +245,7 @@ userApiRequest conf@AppConfig{..} dbStructure req reqBody
|
|||||||
case (contentType, action) of
|
case (contentType, action) of
|
||||||
(_, ActionInvoke InvGet) -> S.fromList $ fst <$> rpcQParams
|
(_, ActionInvoke InvGet) -> S.fromList $ fst <$> rpcQParams
|
||||||
(_, ActionInvoke InvHead) -> S.fromList $ fst <$> rpcQParams
|
(_, ActionInvoke InvHead) -> S.fromList $ fst <$> rpcQParams
|
||||||
(CTOther "application/x-www-form-urlencoded", _) -> S.fromList $ map (toS . fst) $ parseSimpleQuery $ toS reqBody
|
(CTUrlEncoded, _) -> S.fromList $ map (toS . fst) $ parseSimpleQuery $ toS reqBody
|
||||||
_ -> case (relevantPayload, fromRight Nothing parsedColumns) of
|
_ -> case (relevantPayload, fromRight Nothing parsedColumns) of
|
||||||
(Just ProcessedJSON{pjKeys}, _) -> pjKeys
|
(Just ProcessedJSON{pjKeys}, _) -> pjKeys
|
||||||
(Just RawJSON{}, Just cls) -> cls
|
(Just RawJSON{}, Just cls) -> cls
|
||||||
|
|||||||
@@ -659,6 +659,34 @@ spec actualPgVersion =
|
|||||||
it "overloaded(text, text, text)" $
|
it "overloaded(text, text, text)" $
|
||||||
get "/rpc/overloaded?a=1&b=2&c=3" `shouldRespondWith` [json|"123"|]
|
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
|
context "only for POST rpc" $ do
|
||||||
it "gives a parse filter error if GET style proc args are specified" $
|
it "gives a parse filter error if GET style proc args are specified" $
|
||||||
post "/rpc/sayhello?name=John" [json|{}|] `shouldRespondWith` 400
|
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
|
select a || b || c
|
||||||
$$ language sql;
|
$$ 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(
|
create table test.leak(
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
blob bytea
|
blob bytea
|
||||||
|
|||||||
Reference in New Issue
Block a user