From 1af7cbe7fe5d015ba46b003f61afc3f606ba896a Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 22 Jul 2015 17:17:55 -0400 Subject: Allow file access apis to respond to HEAD requests --- api/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/file.go') diff --git a/api/file.go b/api/file.go index 3ef50fbbd..123cab457 100644 --- a/api/file.go +++ b/api/file.go @@ -33,7 +33,7 @@ func InitFile(r *mux.Router) { sr := r.PathPrefix("/files").Subrouter() sr.Handle("/upload", ApiUserRequired(uploadFile)).Methods("POST") - sr.Handle("/get/{channel_id:[A-Za-z0-9]+}/{user_id:[A-Za-z0-9]+}/{filename:([A-Za-z0-9]+/)?.+(\\.[A-Za-z0-9]{3,})?}", ApiAppHandler(getFile)).Methods("GET") + sr.Handle("/get/{channel_id:[A-Za-z0-9]+}/{user_id:[A-Za-z0-9]+}/{filename:([A-Za-z0-9]+/)?.+(\\.[A-Za-z0-9]{3,})?}", ApiAppHandler(getFile)).Methods("GET", "HEAD") sr.Handle("/get_public_link", ApiUserRequired(getPublicLink)).Methods("POST") } -- cgit v1.2.3-1-g7c22 From 2e5528542d532adb81b038cf14c0bae696fec03a Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 29 Jul 2015 10:21:31 -0400 Subject: Changed file API to not write response data on a HEAD request --- api/file.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'api/file.go') diff --git a/api/file.go b/api/file.go index 123cab457..219cf6103 100644 --- a/api/file.go +++ b/api/file.go @@ -261,7 +261,10 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=2592000, public") w.Header().Set("Content-Length", strconv.Itoa(len(f))) - w.Write(f) + + if r.Method != "HEAD" { + w.Write(f) + } } func asyncGetFile(path string, fileData chan []byte) { -- cgit v1.2.3-1-g7c22