Skip to content

Commit

Permalink
Improve error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
adyatlov committed Jun 1, 2016
1 parent 200624c commit bc99e61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion s3proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func serve(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r)
return
}
defer s3resp.Body.Close()

if s3resp.ContentDisposition != nil {
w.Header().Add("Content-Disposition", *s3resp.ContentDisposition)
Expand All @@ -101,7 +102,10 @@ func serve(w http.ResponseWriter, r *http.Request) {
}

nBytes, err := io.Copy(w, s3resp.Body)
s3resp.Body.Close()
if err != nil {
log.Println("Error occured during copying:", err)
return
}
log.Printf("%v: %v bytes are copied.\n", r.URL.EscapedPath(), nBytes)
}

Expand Down

0 comments on commit bc99e61

Please sign in to comment.