Coder Social home page Coder Social logo

Comments (5)

xyproto avatar xyproto commented on May 23, 2024

Thanks for reporting! I think this is a good idea.

from algernon.

diyism avatar diyism commented on May 23, 2024

Indeed, I've tested the two mini lua web servers: redbean and mako,
both of them have an async method now:
redbean: jart/cosmopolitan#615 (comment)
mako: RealTimeLogic/BAS#4 (comment)

from algernon.

xyproto avatar xyproto commented on May 23, 2024

end is already a reserved keyword in Lua, but I added a close() function. It sends a Connection: close header to the connected client, flushes the body and tries to stop Lua functions from writing any more data to the client.

It is also possible to get hold of the net.Conn and then close that one, but it's a tiny bit more involved, since one has to set up a ConnContext field for all involved Server structs that are in use in Algernon.

Please test if the current functionality in the main branch is sufficient to solve this issue. Thanks.

from algernon.

diyism avatar diyism commented on May 23, 2024

Thanks for your response.
I've tested it with the following:

$ git clone --depth 1 https://github.com/xyproto/algernon/
$ cd algernon
$ go build -mod=vendor
$ sudo cp algernon /usr/local/bin/
$ mkdir www
$ cd www
$ cat sleep.lua
sleep(3)
print("welcome, my user")
$ cat index.lua
print("bye bye, my user")
close()
GET("http://127.0.0.1:3000/sleep.lua")
$ algernon

then I visit http://127.0.0.1:3000/index.lua
it still cost about 3 seconds to show "bye bye, my user"
it seems there is a problem somewhere.

from algernon.

xyproto avatar xyproto commented on May 23, 2024

Thanks for testing! I'll add code to close the actual connection.

from algernon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.