• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版00f78045455bafcf6bc5ffe780497ad35a14df17 (tree)
时间2020-02-12 16:38:33
作者mars <mars@byto...>
Commitermars

Log Message

add body close for http request

更改概述

差异

--- a/api/api.go
+++ b/api/api.go
@@ -336,6 +336,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore
336336 authenticator := authn.NewAPI(accessTokens, authDisable)
337337
338338 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
339+ defer req.Body.Close()
339340 // TODO(tessr): check that this path exists; return early if this path isn't legit
340341 req, err := authenticator.Authenticate(req)
341342 if err != nil {
@@ -351,6 +352,7 @@ func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore
351352 // RedirectHandler redirect to dashboard handler
352353 func RedirectHandler(next http.Handler) http.Handler {
353354 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
355+ defer req.Body.Close()
354356 if req.URL.Path == "/" {
355357 http.Redirect(w, req, "/dashboard/", http.StatusFound)
356358 return
@@ -361,6 +363,7 @@ func RedirectHandler(next http.Handler) http.Handler {
361363
362364 func walletHandler(m *http.ServeMux, walletEnable bool) http.Handler {
363365 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
366+ defer req.Body.Close()
364367 // when the wallet is not been opened and the url path is not been found, modify url path to error,
365368 // and redirect handler to error
366369 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