mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Prevent superfluous response.WriteHeader (#15456)
This PR simply checks the status before writing the header. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		@@ -4,7 +4,9 @@
 | 
			
		||||
 | 
			
		||||
package context
 | 
			
		||||
 | 
			
		||||
import "net/http"
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ResponseWriter represents a response writer for HTTP
 | 
			
		||||
type ResponseWriter interface {
 | 
			
		||||
@@ -60,8 +62,10 @@ func (r *Response) WriteHeader(statusCode int) {
 | 
			
		||||
		}
 | 
			
		||||
		r.beforeExecuted = true
 | 
			
		||||
	}
 | 
			
		||||
	if r.status == 0 {
 | 
			
		||||
		r.status = statusCode
 | 
			
		||||
		r.ResponseWriter.WriteHeader(statusCode)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Flush flush cached data
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user