mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 08:35:27 +08:00 
			
		
		
		
	Set status code directly (#608)
Makes it possible for middlewares to read status codes and handle errors
This commit is contained in:
		
				
					committed by
					
						
						Tom Pallister
					
				
			
			
				
	
			
			
			
						parent
						
							44f8e312a8
						
					
				
				
					commit
					f934620538
				
			@@ -43,14 +43,7 @@ namespace Ocelot.Responder
 | 
				
			|||||||
                AddHeaderIfDoesntExist(context, new Header("Content-Length", new []{ response.Content.Headers.ContentLength.ToString() }) );
 | 
					                AddHeaderIfDoesntExist(context, new Header("Content-Length", new []{ response.Content.Headers.ContentLength.ToString() }) );
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            context.Response.OnStarting(state =>
 | 
					            context.Response.StatusCode = (int)response.StatusCode;
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var httpContext = (HttpContext)state;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                httpContext.Response.StatusCode = (int)response.StatusCode;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                return Task.CompletedTask;
 | 
					 | 
				
			||||||
            }, context);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            using(content)
 | 
					            using(content)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user