From 238b6128603017e3b646e425ec0e598bc4004ab6 Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Sun, 21 Feb 2021 22:43:02 -0500 Subject: [PATCH] Update upload.go --- upload.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/upload.go b/upload.go index 3d81082..279e7fb 100644 --- a/upload.go +++ b/upload.go @@ -53,6 +53,12 @@ type Upload struct { } func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { + if !strictReferrerCheck(r, getSiteURL(r), []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}) { + badRequestHandler(c, w, r, RespAUTO, "") + return + } + + upReq := UploadRequest{} contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) if err != nil { upReq.contentSize = 0 @@ -62,12 +68,6 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { log.Printf("content size assigned") log.Print(contentSize) } - if !strictReferrerCheck(r, getSiteURL(r), []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}) { - badRequestHandler(c, w, r, RespAUTO, "") - return - } - - upReq := UploadRequest{} uploadHeaderProcess(r, &upReq) contentType := r.Header.Get("Content-Type") @@ -136,6 +136,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { } func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { + upReq := UploadRequest{} contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) if err != nil { upReq.contentSize = 0 @@ -145,9 +146,8 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { log.Printf("content size assigned") log.Print(contentSize) } - upReq := UploadRequest{} uploadHeaderProcess(r, &upReq) - + defer r.Body.Close() upReq.filename = c.URLParams["name"] upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize)