RealTimeLogic / BAS

Embedded Web Server Library with Integrated Scripting Engine
https://realtimelogic.com/products/barracuda-application-server/
GNU General Public License v2.0
61 stars 14 forks source link

[Feature Request] to close the response output stream early: "response:eof()" #4

Closed diyism closed 2 years ago

diyism commented 2 years ago

In nginx-lua/openresty, I can close the http response early (avoid my users waiting) and continue doing things that cost time on my server:

ngx.say("bye bye, my user")
ngx.eof()
local http=require"httpc".create()
http:request{method="GET", url="https://a web page of very long content"}
local data,err=http:read"*a"

Does the Mako web server have such an API? for example: response:eof()

diyism commented 2 years ago

Although there's another async method:

<html>
  <body>
        <?lsp
        response:write("Hello World<br/>")

        local function q()
                local http=require"httpc".create()
                http:request{method="GET",
                             url="https://a web page of very long content"
                            }
                local data,err=http:read"*a"
                os.execute("/usr/bin/sudo /home/malcolm/lcus1.sh")
        end
        ba.timer(q):set(0)
        ?>
  </body>
</html>

Mako seb server is very slim and strong.

surfskidude commented 2 years ago

In mako, you would do the following to end the response (you defer the execution of the http client): ba.thread.run(function() local http=require"httpc".create() http:request{method="GET", url="https://a web page of very long content"} local data,err=http:read"*a" end)