From dcf2b4fc29b852a6980a21fe6726b2980ae2fda4 Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Sun, 21 Feb 2021 21:28:25 -0500 Subject: [PATCH] Update upload.go --- upload.go | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/upload.go b/upload.go index af68a13..059dc81 100644 --- a/upload.go +++ b/upload.go @@ -56,6 +56,9 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { badRequestHandler(c, w, r, RespAUTO, "") return } + if len(r.Header.Get("Test-Header")) > 0 { + oopsHandler(c, w, r, RespHTML, "You killed it") + } upReq := UploadRequest{} uploadHeaderProcess(r, &upReq) @@ -95,16 +98,6 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { upReq.randomBarename = true } upReq.srcIp = r.Header.Get("X-Forwarded-For") - - if len(r.Header.Get("Content-Length")) > 0 { - i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) - if err == nil { - if i > Config.maxSize { - oopsHandler(c, w, r, RespJSON, "Could not upload file: ") - } - } - } - upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) { @@ -133,6 +126,9 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { } func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { + if len(r.Header.Get("Test-Header")) > 0 { + oopsHandler(c, w, r, RespHTML, "You killed it") + } upReq := UploadRequest{} uploadHeaderProcess(r, &upReq) @@ -140,16 +136,6 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { upReq.filename = c.URLParams["name"] upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize) upReq.srcIp = r.Header.Get("X-Forwarded-For") - - if len(r.Header.Get("Content-Length")) > 0 { - i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) - if err == nil { - if i > Config.maxSize { - oopsHandler(c, w, r, RespJSON, "Could not upload file: ") - } - } - } - upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) { @@ -222,16 +208,6 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) { upReq.randomBarename = r.FormValue("randomize") == "yes" upReq.expiry = parseExpiry(r.FormValue("expiry")) upReq.srcIp = r.Header.Get("X-Forwarded-For") - - if len(r.Header.Get("Content-Length")) > 0 { - i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) - if err == nil { - if i > Config.maxSize { - oopsHandler(c, w, r, RespJSON, "Could not upload file: ") - } - } - } - upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) {