Skip to content

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

Closed

Description

@diyism

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()

Activity

  1. changed the title [-][Feature Request] Explicitly close the response output stream: "response:eof()"[/-] [+][Feature Request] to close the response output stream early: "response:eof()"[/+] on Sep 18, 2022
  2. diyism commented on Sep 18, 2022

    @diyism
    Author

    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.

  3. surfskidude commented on Sep 19, 2022

    @surfskidude
    Collaborator

    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)

  4. locked and limited conversation to collaborators on Sep 19, 2022
  5. converted this issue into a discussion #5 on Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions