nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.82k stars 307 forks source link

Query on Multiple http requests on single client - webdis connection #222

Open srimithravemula opened 2 years ago

srimithravemula commented 2 years ago

Hi Nicolasff,

Have a query as following - I was trying a small test case on sending multiple http requests on same client connection to webdis. I see response in any order for the provided requests. Sample example - for key k1 -> value v1, key k2 -> value v2 if i query like GET/k1 and GET/k2 on same client connection to webdis, i can get response v1 and response v2 or reverse order(as response v2 first and response v1). Problem i am facing is there is no way to map between request and response in this case. Is there any option that webdis provides to map between request and response(like example - any http header i can add to store the request?) Or is it not expected to send multiple http requests on same connection without waiting for response? Can you please let me know.

Thanks.

srimithravemula commented 2 years ago

Hi Nicolasff,

Can you please let me know response to above query, when you find some time

Thanks

nicolasff commented 2 years ago

Hi @srimithravemula, sorry for the late reply. There are a couple of things that you could try, those are just what comes to mind now.

One would be to write a Lua script that returns both the key and the value when given a key, so that if you call the script with k1 it return [k1, v1]v1 being the value under k1.

Another approach would be to request each one with a different (custom) Content-Type, if you can handle such replies. This feature is documented here. So you could query /GET/k1?type=k1 immediately followed by /GET/k2?type=k2. The response with Content-Type: k1 is for the first request. This is not ideal, but as a workaround I think it could help.

I hadn't considered this use case, but I agree that it's an issue. I can't really make changes to webdis at this time, so I'll see if some past contributor could look into it.