Skip to content

Commit 64e3be6

Browse files
committed
[Upload] Modify the method after Upload
To fix the gh issue #12 is it necessary to change the HTTP Method so that the folling handler (file_server) is able to read the response template. I'm not sure if this is the best method to fix the issue but it's an working method.
1 parent 46a80b8 commit 64e3be6

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

upload.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
Version = "0.10"
19+
Version = "0.11"
2020
)
2121

2222
func init() {
@@ -283,10 +283,6 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
283283
repl.Set("http.upload.filesize", handler.Size)
284284
repl.Set("http.upload.directory", concatDir)
285285

286-
if u.ResponseTemplate != "" {
287-
r.URL.Path = "/" + u.ResponseTemplate
288-
}
289-
290286
if u.NotifyURL != "" {
291287
errNotify := u.SendNotify(requuid)
292288

@@ -297,8 +293,18 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
297293
}
298294
}
299295

300-
w.WriteHeader(http.StatusCreated)
301-
return nil
296+
if u.ResponseTemplate != "" {
297+
r.URL.Path = "/" + u.ResponseTemplate
298+
/*
299+
* Change the POST method to GET that the following Fileserver
300+
* does not complain about the POST method
301+
*/
302+
if r.Method == "POST" {
303+
r.Method = "GET"
304+
}
305+
}
306+
307+
return next.ServeHTTP(w, r)
302308
}
303309

304310
// Interface guards

0 commit comments

Comments
 (0)