mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-10-31 23:26:35 +08:00 
			
		
		
		
	Fixes "http: multiple response.WriteHeader calls" in 404 [Issue #29]
This commit is contained in:
		
							parent
							
								
									00413032bb
								
							
						
					
					
						commit
						e1781e2db1
					
				
							
								
								
									
										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) { | ||||
| 	handlers := engine.combineHandlers(engine.handlers404) | ||||
| 	c := engine.createContext(w, req, nil, handlers) | ||||
| 	if engine.handlers404 == nil { | ||||
| 		http.NotFound(c.Writer, c.Req) | ||||
| 	} else { | ||||
| 		c.Writer.WriteHeader(404) | ||||
| 	} | ||||
| 
 | ||||
| 	c.Writer.setStatus(404) | ||||
| 	c.Next() | ||||
| 	if !c.Writer.Written() { | ||||
| 		c.String(404, "404 page not found") | ||||
| 	} | ||||
| 	engine.reuseContext(c) | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user