-
Notifications
You must be signed in to change notification settings - Fork 19
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
Callback-Based Response Retrieval #23
Comments
Is it possible to make it api-compatible with luasocket like luasec and lapis do? I think using a single API will be more convenient and clearer than creating a new one. |
No, it's not possible to do so. The intention of lua-https is clear: to make HTTP(S) request using OS-provided or popular library API. If lua-https is modified to have similar API as LuaSec then you're looking for TLS alone. Furthermore, if OS decided to support future HTTP version such as HTTP3 in the future, lua-https doesn't require any change to the API. This is already true for the recent WinINet backend (in Windows) and cURL backend. It will try to use HTTP2 automatically if the OS and the site supports it and fallback to HTTP 1.1 otherwise. Meanwhile if you're using LuaSec-style API, then implementing HTTP2 is difficult, if not impossible. You most likely stuck in HTTP 1.1 protocol. |
Hi, interested to know what the state of this features is. Is it possible to use lua-https for partial responses using a callback to e.g. implement streaming openai api responses? If not please do advise which library would be my best bet for this functionality. Thank you so much! |
There is no callback-based API currently implemented. Also, while I'm interested in implementing something like this and other improvements for general use, I am not interested in helping with AI/LLM-related topics. |
One of the limitation in
lua-https
is that it's not possible for application to create download progress bars on it (if theContent-Length
header is available). This is becausehttps.request
will wait until all the response data is retrieved.My proposal is to add optional 3rd and 4th parameter
callback
andcontext
. Callback is defined as these fields:Example usage:
As an additional feature/requirement, the
callback
table can be a class object (not instance) by retrieving the function list using Lua C function that invokes metamethod and thecontext
can be the class instance itself such that when a class is declared like this:Doing something like this simply works and calls the appropriate functions.
The return value of
https.request
when using this variant would be questionable.true
orfalse
+ error message (assert
-compatible style) means less redundancy, but breaks backward compatibility.I probably can do this, but the question becomes "should this is be done?" and/or "is this valid usecase to justify the feature addition?".
The text was updated successfully, but these errors were encountered: