-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Lua API: Http(s) GET, POST, ... #55
Comments
The API must support both HTTPS and plain HTTP. It must support the POST and GET methods at the least, and HEAD would be nice. Each of these methods must support custom headers (as a Lua table), host (example.com) and target (/index.html) as parameters. The POST method must support a body, with the The function names should be prefixed with the general category, so |
I'll do all that. And when making a request, there will also be an optional Parameter for a callback function to make it non blocking on luas side |
Thats not a good idea. Fundamentally the Lua is single-threaded, so this should be an event, not a callback. |
Why would a callback be blocking? |
And what kind of events would you use? Just emit some kind of multiplayer event? |
it is in lua since it is single threaded if you execute the task on function call it will wait until it returns, however if you have it as an event it will execute that event when the data is ready on that same thread, or you can have it take a function as an argument and call that function while holding the lua mutex |
I meant the second thing you said. The function could have a callback argument:
so the function doesn't actually return anything but it invokes the callback once the request is done |
Its the same with event or callback, as long as you can make a callback work properly, im okay with it. |
Basically, we know how events work, and they have become an idiom that we use, but if you can make a callback work, do that |
Wouldn't an event need some kind of identifier so you don't get the wrong response? |
Youd have to specify your own event name, yeah, as i said i like callbacks, if you can make them work |
So MP.HttpGet could return a random number/string and the event contains that I'd in the args. So Lua can check it the id is correct |
everything is on one thread so you can easily expect the responses in order it will basically be a detached callback |
Ok. I'll try to make a callback |
yeah sounds good |
just make sure to never, ever call lua from any other thread than the one of that state |
justmedev dropped it, it's up for grabs. Http.CreateConnection already exists, as a starting point. |
Otherwise I'll build it for whatever version we do after 3.1.0. |
See specification below.
The text was updated successfully, but these errors were encountered: