Doubidou
Doubidou

Reputation: 1791

Resume a download when Echo server is restarted

I'm trying to make a proxy to download server files with an authentication layer.

I'm using Golang (1.21.0) and Echo (4.11.1)

Problem description

When a user is downloading a big file, if I kill the Echo server (Ctrl+C), the download is just marked as "terminated" instead of being "canceled" or in a "interrupt error" state.

So, the user can't retry it and resume download (with Range headers) later when the server will come up later...

Question

Is there a way to wait every connection when stop server to gracefully interrupt it without killing user downloads ?

Or, better, is there a way to mark the download as "failed" and not just "terminated" ?

Code used

package main

import (
    "net/http"

    "github.com/labstack/echo/v4"
)

func main() {
    e := echo.New()
    e.GET("/file", func(c echo.Context) error {
        return c.Attachment("big_file.zip", "original file name.zip")
    })
    e.Logger.Fatal(e.Start(":1323"))
}

Upvotes: 1

Views: 84

Answers (0)

Related Questions