Fixes "http: multiple response.WriteHeader calls" in 404 [Issue #29]
This commit is contained in:
		
							
								
								
									
										10
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								gin.go
									
									
									
									
									
								
							@ -129,13 +129,11 @@ func (engine *Engine) CacheStress() float32 {
 | 
				
			|||||||
func (engine *Engine) handle404(w http.ResponseWriter, req *http.Request) {
 | 
					func (engine *Engine) handle404(w http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
	handlers := engine.combineHandlers(engine.handlers404)
 | 
						handlers := engine.combineHandlers(engine.handlers404)
 | 
				
			||||||
	c := engine.createContext(w, req, nil, handlers)
 | 
						c := engine.createContext(w, req, nil, handlers)
 | 
				
			||||||
	if engine.handlers404 == nil {
 | 
						c.Writer.setStatus(404)
 | 
				
			||||||
		http.NotFound(c.Writer, c.Req)
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		c.Writer.WriteHeader(404)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	c.Next()
 | 
						c.Next()
 | 
				
			||||||
 | 
						if !c.Writer.Written() {
 | 
				
			||||||
 | 
							c.String(404, "404 page not found")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	engine.reuseContext(c)
 | 
						engine.reuseContext(c)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user