Handle cURL and Wget clients.
This commit is contained in:
parent
b16ec84e86
commit
2ef85c6f29
@ -86,7 +86,11 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if leftSpace < fHandler.Size {
|
||||
log.Println("not enough space left in storage, only", leftSpace>>20, "MiB left")
|
||||
if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") {
|
||||
http.Error(w, "Not enough space left, sorry", http.StatusInternalServerError)
|
||||
} else {
|
||||
web.ErrorNoSpace(utils.MainSite(r.Host), w)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -152,7 +156,11 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") {
|
||||
fmt.Fprintln(w, downloadURLParsed.String(), "will be kept for", h.keepForHours)
|
||||
} else {
|
||||
web.Uploaded(utils.MainSite(r.Host), site, downloadURLParsed.String(), h.keepForHours, w)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
|
||||
@ -214,7 +222,11 @@ func (h *UploadHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
h.logFile.Printf("dt | %s | %s | %s | %s", r.Header.Get("X-Real-IP"), netTyp, saltedHash, r.UserAgent())
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") {
|
||||
fmt.Fprintln(w, "File was successfully deleted.")
|
||||
} else {
|
||||
web.Deleted(utils.MainSite(r.Host), w)
|
||||
}
|
||||
}
|
||||
|
||||
func NotFound(w http.ResponseWriter, r *http.Request) {
|
||||
|
Loading…
Reference in New Issue
Block a user