diff --git a/internal/http/handlers.go b/internal/http/handlers.go index b4a5a90..a9195e8 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -74,10 +74,8 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) { Error(w, r, http.StatusInternalServerError, "Error reading an incoming file.") return } - defer func() { - os.Remove(fHandler.Filename) - f.Close() - }() + defer os.Remove(fHandler.Filename) + defer f.Close() var leftSpace int64 = storCapacity - *h.uploadDirSize @@ -148,13 +146,8 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) { _, scheme := utils.NetworkType(r.Host) site := scheme + "://" + r.Host - if strings.Contains(r.UserAgent(), "curl") { - w.Write([]byte(site + downloadURLParsed.String() + "\r\n")) - return - } - if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") { - fmt.Fprintln(w, downloadURLParsed.String(), "will be kept for", h.keepForHours) + fmt.Fprintln(w, site+downloadURLParsed.String(), "will be kept for", h.keepForHours) } else { web.Uploaded(utils.MainSite(r.Host), site, downloadURLParsed.String(), h.keepForHours, w) }