• R/O
  • HTTP
  • SSH
  • HTTPS

bytom: Commit

Official Go implementation of the Bytom protocol


Commit MetaInfo

Revisionb366f717529707506719d6d283b55004cb9a292c (tree)
Time2020-02-12 17:01:32
Authormars <mars@byto...>
Commitermars

Log Message

add body close for http request

Change Summary

Incremental Difference

--- a/api/api.go
+++ b/api/api.go
@@ -356,6 +356,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore
356356 authenticator := authn.NewAPI(accessTokens, authDisable)
357357
358358 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
359+ defer req.Body.Close()
359360 // TODO(tessr): check that this path exists; return early if this path isn't legit
360361 req, err := authenticator.Authenticate(req)
361362 if err != nil {
@@ -371,6 +372,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore
371372 // RedirectHandler redirect to dashboard handler
372373 func RedirectHandler(next http.Handler) http.Handler {
373374 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
375+ defer req.Body.Close()
374376 if req.URL.Path == "/" {
375377 http.Redirect(w, req, "/dashboard/", http.StatusFound)
376378 return
@@ -381,6 +383,7 @@ func RedirectHandler(next http.Handler) http.Handler {
381383
382384 func walletHandler(m *http.ServeMux, walletEnable bool) http.Handler {
383385 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
386+ defer req.Body.Close()
384387 // when the wallet is not been opened and the url path is not been found, modify url path to error,
385388 // and redirect handler to error
386389 if _, pattern := m.Handler(req); pattern != req.URL.Path && !walletEnable {
--- a/net/http/static/static.go
+++ b/net/http/static/static.go
@@ -29,6 +29,7 @@ type Handler struct {
2929 }
3030
3131 func (h Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
32+ defer r.Body.Close()
3233 output, ok := h.Assets[r.URL.Path]
3334 if !ok && r.URL.Path == "" && h.Index != "" {
3435 output = h.Assets[h.Index]
Show on old repository browser