"Empty reply from server" for long-running task in http handler

Hey folks, I have a quick question. I have a very straightforward endpoint that triggers some long-running action in my web service (re-ordering files on the filesystem), let’s imagine it takes 10-15 seconds:

func rebuildHandler(appcfg *cfg.Config) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

         // emulate workload
        time.Sleep(10 * time.Second)

        // no errors returned
        w.WriteHeader(http.StatusOK)
        w.Header().Set("Content-Type", "application/text")
        w.Write([]byte("OK"))
    }
}

when I trigger this endpoint with curl

curl -i "http://localhost:8080/rebuild"

it says “curl: (52) Empty reply from server” If there are fewer files (< 1Gb), and the re-ordering performs faster (0-5 seconds) - the server replies with 200 OK.

Does it depend on the client? Are there any chances to make the client wait for the reply?
ps. I tried --connect-timeout in curl, but no luck

Cheerz,
Pasha

net.http.Server.WriteTimeout maybe?

Thank you, Jeff!
Initially, this parameter was set (by myself) to the low value!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.