Bo-Yi Wu 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							234a6d4c00 
							
						 
					 
					
						
						
							
							fix(response): refine hijack behavior for response lifecycle ( #4373 )  
						
						 
						
						... 
						
						
						
						* feat: refine hijack behavior for response lifecycle and add tests
- Clarify the error message for attempted hijack after response body data is written
- Modify hijack behavior: allow hijacking after headers are written (for better websocket compatibility), but block hijacking after any body data is sent
- Add comprehensive tests to validate allowed hijack after header write and disallowed hijack after body write
fix https://github.com/gin-gonic/gin/issues/4372 
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* test: use require for immediate test failure on errors
- Replace assert with require for error checks to ensure test failures immediately halt execution
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Update response_writer.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> 
						
						
					 
					
						2025-09-26 08:13:39 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								諏訪原慶斗 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							32065bbd42 
							
						 
					 
					
						
						
							
							chore(response): prevention of Hijack() runtime panics ( #4295 )  
						
						 
						
						... 
						
						
						
						* Prevention of Hijack() runtime panics
* added test of Hijack()
* fix review
* fix lint error
* added check assertion of Wrrten() condition before calling Hijack() 
						
						
					 
					
						2025-08-02 12:16:58 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								David Desmarais-Michaud 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							c1d06e3d08 
							
						 
					 
					
						
						
							
							add supprt for go1.20 http.rwUnwrapper to gin.responseWriter ( #3489 )  
						
						 
						
						
						
						
					 
					
						2023-02-12 13:01:43 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Alireza (Pure) 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							41f2669ebc 
							
						 
					 
					
						
						
							
							console logger HTTP status bug fixed and the corresponding unit test added ( #3453 )  
						
						 
						
						
						
						
					 
					
						2023-01-02 11:38:53 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Jesse 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							51aea73ba0 
							
						 
					 
					
						
						
							
							fix: modify interface check way ( #3327 )  
						
						 
						
						
						
						
					 
					
						2022-10-20 00:49:19 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								thinkerou 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							4b68a5f12a 
							
						 
					 
					
						
						
							
							chore: update go.mod and remove space from copyright ( #3158 )  
						
						 
						
						... 
						
						
						
						Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 
						
						
					 
					
						2022-05-28 10:42:28 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								mstmdev 
							
						 
					 
					
						
						
							
							
						
						
						
							
						
						
							865fd560fc 
							
						 
					 
					
						
						
							
							Update some comments, add function name prefix to comment ( #3090 )  
						
						 
						
						
						
						
					 
					
						2022-03-23 21:35:09 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Dan Markham 
							
						 
					 
					
						
						
						
						
							
						
						
							094f9a9105 
							
						 
					 
					
						
						
							
							v1.4.0 +  #1631  (remove go1.6/go1,7 support) ( #1851 )  
						
						 
						
						... 
						
						
						
						* remove go1.6 support
* remove build tag
* remove todo
* remove go1.6 support: https://github.com/gin-gonic/gin/pull/1383/commits 
* update readme
* remove go1.7 support
* fix embedmd error
* test
* revert it
* revert it
* remove context_17
* add pusher test
* v1.4.0 rc1 
						
						
					 
					
						2019-05-07 18:32:32 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								zhanweidu 
							
						 
					 
					
						
						
						
						
							
						
						
							0552c3bc3a 
							
						 
					 
					
						
						
							
							flush operation will overwrite the origin status code ( #1460 )  
						
						 
						
						... 
						
						
						
						The status of responseWriter will be overwrite if flush was called. This is caused by the Flush of http.response.Flush(). 
						
						
					 
					
						2018-08-07 12:41:28 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								田欧 
							
						 
					 
					
						
						
						
						
							
						
						
							6c6d97ba2e 
							
						 
					 
					
						
						
							
							remove hardcode instead of http status value ( #1411 )  
						
						 
						
						
						
						
					 
					
						2018-06-26 17:21:32 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								htobenothing 
							
						 
					 
					
						
						
						
						
							
						
						
							bf85b32c1d 
							
						 
					 
					
						
						
							
							Add Pusher() function for support http2 server push ( #1273 )  
						
						 
						
						... 
						
						
						
						gin already support http2, while previously not support server push.
Add Pusher() function to extend the ResponseWriter interface.
```golang
// get http.Pusher
 if pusher := c.Writer.Pusher(); pusher != nil {
     // use pusher.Push() to do server push
}
```
<img width="881" alt="screen shot 2018-03-07 at 11 20 49 pm" src="https://user-images.githubusercontent.com/16014993/37100619-680c00c6-225e-11e8-9352-76ec3bd62894.png "> 
						
						
					 
					
						2018-06-21 09:53:52 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								田欧 
							
						 
					 
					
						
						
						
						
							
						
						
							a8fa424ae5 
							
						 
					 
					
						
						
							
							update comment ( #1057 )  
						
						 
						
						
						
						
					 
					
						2017-08-16 11:55:50 +08:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								田欧 
							
						 
					 
					
						
						
						
						
							
						
						
							b985857899 
							
						 
					 
					
						
						
							
							update func comment ( #981 )  
						
						 
						
						
						
						
					 
					
						2017-07-05 20:28:16 -05:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								田欧 
							
						 
					 
					
						
						
						
						
							
						
						
							d535fcd598 
							
						 
					 
					
						
						
							
							separate type define ( #975 )  
						
						 
						
						
						
						
					 
					
						2017-07-05 02:47:36 -05:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							8f3047814e 
							
						 
					 
					
						
						
							
							Comments + IRoutes + IRouter + unexported AbortIndex  
						
						 
						
						
						
						
					 
					
						2015-07-02 20:24:54 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							835f66fdc9 
							
						 
					 
					
						
						
							
							404 not found performance improvements  
						
						 
						
						... 
						
						
						
						benchmark            old ns/op     new ns/op     delta
Benchmark404         737           249           -66.21%
Benchmark404Many     2330          454           -80.52%
benchmark            old allocs     new allocs     delta
Benchmark404         3              0              -100.00%
Benchmark404Many     10             0              -100.00%
benchmark            old bytes     new bytes     delta
Benchmark404         115           68            -40.87%
Benchmark404Many     235           57            -75.74% 
						
						
					 
					
						2015-05-30 14:45:13 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							59c836e1fa 
							
						 
					 
					
						
						
							
							Only emit a warning is the status code changes  
						
						 
						
						
						
						
					 
					
						2015-05-12 18:31:31 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							99694bb716 
							
						 
					 
					
						
						
							
							Fixes errors  
						
						 
						
						
						
						
					 
					
						2015-05-12 15:22:13 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							c61c547539 
							
						 
					 
					
						
						
							
							More unit tests for ResponseWriter  
						
						 
						
						
						
						
					 
					
						2015-04-08 15:20:39 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							598c78297c 
							
						 
					 
					
						
						
							
							NoWritten and DefaultStatus must be unexported variables  
						
						 
						
						
						
						
					 
					
						2015-04-07 18:50:16 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							34b1d0262e 
							
						 
					 
					
						
						
							
							Refactors response_writer.go  
						
						 
						
						
						
						
					 
					
						2015-03-23 04:45:33 +01:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							251b73fc70 
							
						 
					 
					
						
						
							
							Fixes   #239  bug  
						
						 
						
						
						
						
					 
					
						2015-03-23 04:45:03 +01:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							21e53c0db6 
							
						 
					 
					
						
						
							
							Fixes responseWriter.Size()  
						
						 
						
						... 
						
						
						
						- "written" boolean is not longer needed
- size is reseted
- addition instead of assignation 
						
						
					 
					
						2014-09-03 04:25:08 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Matt Newberry 
							
						 
					 
					
						
						
						
						
							
						
						
							daedc0bc17 
							
						 
					 
					
						
						
							
							Add response body size to writer interface  
						
						 
						
						
						
						
					 
					
						2014-09-02 13:17:37 -04:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							3b079bb6f7 
							
						 
					 
					
						
						
							
							Merge branch 'master' into develop  
						
						 
						
						
						
						
					 
					
						2014-08-29 19:50:58 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							8e5397bfa0 
							
						 
					 
					
						
						
							
							Adds in-code license  
						
						 
						
						
						
						
					 
					
						2014-08-29 19:49:50 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							8f1bbc6b6a 
							
						 
					 
					
						
						
							
							gin.responseWriter implements http.Flusher and http.CloseNotifier  
						
						 
						
						
						
						
					 
					
						2014-08-26 17:52:58 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							7a87c5cbd4 
							
						 
					 
					
						
						
							
							Referencing the http.Hijacker interface  
						
						 
						
						
						
						
					 
					
						2014-08-26 17:50:07 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								olebedev 
							
						 
					 
					
						
						
						
						
							
						
						
							4a24c47a69 
							
						 
					 
					
						
						
							
							Hijacker interface added  
						
						 
						
						
						
						
					 
					
						2014-08-25 15:58:43 +04:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							b3f322c5fc 
							
						 
					 
					
						
						
							
							Fixes bug when status code is negative  
						
						 
						
						
						
						
					 
					
						2014-08-24 04:35:11 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							e11ff5bacb 
							
						 
					 
					
						
						
							
							response_writes uses 200 as default status code.  
						
						 
						
						
						
						
					 
					
						2014-08-18 19:48:01 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							dcafad3ced 
							
						 
					 
					
						
						
							
							Deferring WriteHeader. Part 1  
						
						 
						
						
						
						
					 
					
						2014-08-18 05:24:48 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							48f4914165 
							
						 
					 
					
						
						
							
							Performance improvement  
						
						 
						
						... 
						
						
						
						- Reduces number of allocations per context
- Improves CPU cache usage 
						
						
					 
					
						2014-07-18 00:10:28 +02:00  
					
					
						 
						
							
							
							 
						
					 
				 
			
				
					
						
							
							
								 
								Manu Mtz-Almeida 
							
						 
					 
					
						
						
						
						
							
						
						
							d42aa6d868 
							
						 
					 
					
						
						
							
							Fixes wrap around http.ResponseWriter  
						
						 
						
						
						
						
					 
					
						2014-07-04 00:01:28 +02:00