File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,25 @@ const (
2525 maxBodyBytes = 32 * 1024 * 1024
2626)
2727
28+ var djangoHTTPMethods = map [string ]struct {}{
29+ http .MethodGet : {},
30+ http .MethodHead : {},
31+ http .MethodPost : {},
32+ http .MethodPut : {},
33+ http .MethodPatch : {},
34+ http .MethodDelete : {},
35+ http .MethodOptions : {},
36+ http .MethodTrace : {},
37+ }
38+
39+ func handleUnsupportedHTTPMethod (rw http.ResponseWriter , r * http.Request ) bool {
40+ if _ , ok := djangoHTTPMethods [r .Method ]; ok {
41+ return false
42+ }
43+ http .Error (rw , "Unsupported HTTP method." , http .StatusNotImplemented )
44+ return true
45+ }
46+
2847func (ws * WebServer ) configureProxy () {
2948 // Reverse proxy to the application server
3049 director := func (req * http.Request ) {
@@ -84,6 +103,10 @@ func (ws *WebServer) configureProxy() {
84103 return
85104 }
86105
106+ if handleUnsupportedHTTPMethod (rw , r ) {
107+ return
108+ }
109+
87110 r .Body = http .MaxBytesReader (rw , r .Body , maxBodyBytes )
88111 rp .ServeHTTP (rw , r )
89112
You can’t perform that action at this time.
0 commit comments