From 05df7fc45378db4e0de42a1c42cb6b99901aea44 Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Wed, 17 May 2017 10:29:41 +0700 Subject: [PATCH] Add Max-Hours and Max-Seconds Better will be to avoid copy-paste here and to use not headers for params, but url's params, like: `curl --upload-file ./hello.txt https://transfer.sh/hello.txt?max-downloads=5` --- server/handlers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/handlers.go b/server/handlers.go index 8c55db2..84bb8c3 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -319,6 +319,18 @@ func MetadataForRequest(contentType string, r *http.Request) Metadata { metadata.MaxDate = time.Now().Add(time.Hour * 24 * time.Duration(v)) } + if v := r.Header.Get("Max-Hours"); v == "" { + } else if v, err := strconv.Atoi(v); err != nil { + } else { + metadata.MaxDate = time.Now().Add(time.Hour * time.Duration(v)) + } + + if v := r.Header.Get("Max-Seconds"); v == "" { + } else if v, err := strconv.Atoi(v); err != nil { + } else { + metadata.MaxDate = time.Now().Add(time.Second * time.Duration(v)) + } + return metadata }