mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
plugin/clnrest: do not read json payload if data length is zero
OpenAPI readme always includes `content-type: application/json` header, even when body parameters are empty. But the server expects data if the content-type has been sent. This results in a "Server Error" response for non-param requests from readme doc. This only affects readme requests as it is designed to send the header by default. Changelog-None
This commit is contained in:
parent
f4f4ab34f3
commit
e788f76f99
@ -48,7 +48,10 @@ class RpcMethodResource(Resource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if request.is_json:
|
if request.is_json:
|
||||||
|
if len(request.data) != 0:
|
||||||
payload = request.get_json()
|
payload = request.get_json()
|
||||||
|
else:
|
||||||
|
payload = {}
|
||||||
else:
|
else:
|
||||||
payload = request.form.to_dict()
|
payload = request.form.to_dict()
|
||||||
return call_rpc_method(plugin, rpc_method, payload), 201
|
return call_rpc_method(plugin, rpc_method, payload), 201
|
||||||
|
@ -53,7 +53,10 @@ def verify_rune(plugin, request):
|
|||||||
raise Exception('{ "error": {"code": 403, "message": "Not authorized: Missing rune"} }')
|
raise Exception('{ "error": {"code": 403, "message": "Not authorized: Missing rune"} }')
|
||||||
|
|
||||||
if request.is_json:
|
if request.is_json:
|
||||||
|
if len(request.data) != 0:
|
||||||
rpc_params = request.get_json()
|
rpc_params = request.get_json()
|
||||||
|
else:
|
||||||
|
rpc_params = {}
|
||||||
else:
|
else:
|
||||||
rpc_params = request.form.to_dict()
|
rpc_params = request.form.to_dict()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user