mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-10-31 07:02:13 +08:00 
			
		
		
		
	Context.Data() takes content-type
This commit is contained in:
		
							parent
							
								
									f387bdda9e
								
							
						
					
					
						commit
						aadd33af2c
					
				
							
								
								
									
										9
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								gin.go
									
									
									
									
									
								
							| @ -480,7 +480,12 @@ func (c *Context) String(code int, msg string) { | ||||
| } | ||||
| 
 | ||||
| // Writes some data into the body stream and updates the HTTP code. | ||||
| func (c *Context) Data(code int, data []byte) { | ||||
| 	c.Writer.WriteHeader(code) | ||||
| func (c *Context) Data(code int, contentType string, data []byte) { | ||||
| 	if len(contentType) > 0 { | ||||
| 		c.Writer.Header().Set("Content-Type", contentType) | ||||
| 	} | ||||
| 	if code >= 0 { | ||||
| 		c.Writer.WriteHeader(code) | ||||
| 	} | ||||
| 	c.Writer.Write(data) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user