presto-python-client
presto-python-client copied to clipboard
nextUri should be parsed instead of being consumed directly
What happend
When accessing presto behind a HTTPS proxy, this python sdk won't work when trying to following up the nextUri
from query statement. E.g., after creating a query, when following statement:
$ curl -k https://192.168.86.20:31947/v1/statement/queued/20200731_194504_00002_azxv3/y61f7c68358f1460750b1f4fca89c4b272c55d0b3/1
{"id":"20200731_194504_00002_azxv3","infoUri":"http://192.168.86.20:8080/ui/query.html?20200731_194504_00002_azxv3","nextUri":"http://192.168.86.20:8080/v1/statement/executing/20200731_194504_00002_azxv3/ya4b5bce0c6391da9d771a40df96d4723d2280b81/0","stats":{"state":"QUEUED","queued":true,"scheduled":false,"nodes":0,"totalSplits":0,"queuedSplits":0,"runningSplits":0,"completedSplits":0,"cpuTimeMillis":0,"wallTimeMillis":0,"queuedTimeMillis":29,"elapsedTimeMillis":381605,"processedRows":0,"processedBytes":0,"peakMemoryBytes":0,"spilledBytes":0},"warnings":[]}
Notice that the nextUri
does not starts with HTTPS.
As a consequence, the python client will fail since it tries to use the value of this nextUri
directly:
https://github.com/prestodb/presto-python-client/blob/b87744e51f557fdff9c5d230a2e1d4dfb7d733ee/prestodb/client.py#L337-L340
Expected outcome
It should parse the value of nextUri
then format it just like that for the statement url.
After using server configuration option http-server.process-forwarded=true
from https://github.com/prestosql/presto/pull/3714 I don't have this problem anymore.
This case only happens when http-server.process-forwarded=false
where it won't use the expect scheme when presto is behind a HTTPS proxy.