public void AddResponseHeader_Success(string startValue, int status, string value, bool append, bool always, string expected) { var httpContext = new DefaultHttpContext(); var response = new HttpResponseMessage(); httpContext.Response.StatusCode = status; var transform = new ResponseHeaderValueTransform(value, append, always); var result = transform.Apply(httpContext, response, startValue.Split(";", System.StringSplitOptions.RemoveEmptyEntries)); Assert.Equal(expected.Split(";", System.StringSplitOptions.RemoveEmptyEntries), result); }
public async Task AddResponseHeader_Success(string startValue, int status, string value, bool append, bool always, string expected) { var httpContext = new DefaultHttpContext(); httpContext.Response.Headers["name"] = startValue.Split(";", System.StringSplitOptions.RemoveEmptyEntries); httpContext.Response.StatusCode = status; var transformContext = new ResponseTransformContext() { HttpContext = httpContext, ProxyResponse = new HttpResponseMessage(), HeadersCopied = true, }; var transform = new ResponseHeaderValueTransform("name", value, append, always); await transform.ApplyAsync(transformContext); Assert.Equal(expected.Split(";", System.StringSplitOptions.RemoveEmptyEntries), httpContext.Response.Headers["name"]); }