From a284e89e2833191660dfc547e18ce9965e6b68ad Mon Sep 17 00:00:00 2001 From: Acconut Date: Fri, 31 Jul 2015 12:35:21 +0200 Subject: [PATCH] Add Tus-Method-Override header --- handler.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/handler.go b/handler.go index 8f6c14c..5935cf3 100644 --- a/handler.go +++ b/handler.go @@ -121,6 +121,13 @@ func NewHandler(config Config) (*Handler, error) { // Implement the http.Handler interface. func (handler *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Allow overriding the HTTP method. The reason for this is + // that some libraries/environments to not support PATCH and + // DELETE requests, e.g. Flash in a browser and parts of Java + if newMethod := r.Header.Get("Tus-Method-Override"); newMethod != "" { + r.Method = newMethod + } + go logger.Println(r.Method, r.URL.Path) header := w.Header()