Skip to content

Commit

Permalink
Unset WriteTimeout to allow streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Mar 25, 2021
1 parent 9e2345c commit 8317283
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ func HTTPServer(
}

return &http.Server{
Addr: config.Listen,
Handler: handler,
ReadTimeout: time.Second * 5,
WriteTimeout: time.Second * 10,
Addr: config.Listen,
Handler: handler,
ReadTimeout: time.Second * 5,
// WriteTimeout is set to 0 because we have streaming endpoints.
// https://github.com/golang/go/issues/16100#issuecomment-285573480
WriteTimeout: 0,
IdleTimeout: time.Second * 120,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/collection/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (dp *downloadReverseProxy) modifyResponse(r *http.Response) error {
func (dp *downloadReverseProxy) errorHandler(rw http.ResponseWriter, req *http.Request, err error) {
rw.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(rw, `{"message": "The operation failed unexpectedly. Contact the administrator for more details."}`)
dp.logger.Info("Download from Storage Service failed", "msg", err)
dp.logger.Info("Download from Storage Service failed", "msg", err.Error())
}

func (p *downloadReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
Expand Down

0 comments on commit 8317283

Please sign in to comment.