Official Go implementation of the Bytom protocol
Revision | b366f717529707506719d6d283b55004cb9a292c (tree) |
---|---|
Time | 2020-02-12 17:01:32 |
Author | mars <mars@byto...> |
Commiter | mars |
add body close for http request
@@ -356,6 +356,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore | ||
356 | 356 | authenticator := authn.NewAPI(accessTokens, authDisable) |
357 | 357 | |
358 | 358 | return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
359 | + defer req.Body.Close() | |
359 | 360 | // TODO(tessr): check that this path exists; return early if this path isn't legit |
360 | 361 | req, err := authenticator.Authenticate(req) |
361 | 362 | if err != nil { |
@@ -371,6 +372,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore | ||
371 | 372 | // RedirectHandler redirect to dashboard handler |
372 | 373 | func RedirectHandler(next http.Handler) http.Handler { |
373 | 374 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
375 | + defer req.Body.Close() | |
374 | 376 | if req.URL.Path == "/" { |
375 | 377 | http.Redirect(w, req, "/dashboard/", http.StatusFound) |
376 | 378 | return |
@@ -381,6 +383,7 @@ func RedirectHandler(next http.Handler) http.Handler { | ||
381 | 383 | |
382 | 384 | func walletHandler(m *http.ServeMux, walletEnable bool) http.Handler { |
383 | 385 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
386 | + defer req.Body.Close() | |
384 | 387 | // when the wallet is not been opened and the url path is not been found, modify url path to error, |
385 | 388 | // and redirect handler to error |
386 | 389 | if _, pattern := m.Handler(req); pattern != req.URL.Path && !walletEnable { |
@@ -29,6 +29,7 @@ type Handler struct { | ||
29 | 29 | } |
30 | 30 | |
31 | 31 | func (h Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { |
32 | + defer r.Body.Close() | |
32 | 33 | output, ok := h.Assets[r.URL.Path] |
33 | 34 | if !ok && r.URL.Path == "" && h.Index != "" { |
34 | 35 | output = h.Assets[h.Index] |