public void Should_override_the_content_type() { var response = formatter.AsText("sample text", "text/cache-manifest"); using (var stream = new MemoryStream()) { response.Contents(stream); response.ContentType.ShouldEqual("text/cache-manifest; charset=utf-8"); } }
public static Response AsNonCachedText(this IResponseFormatter responseFormatter, string responseText) { if (responseFormatter == null) { throw new ArgumentNullException("responseFormatter"); } return(responseFormatter.AsText(responseText) .WithHeader("Cache-Control", "no-cache, no-store, must-revalidate") .WithHeader("Pragma", "no-cache") .WithHeader("Expires", "0")); }
public static Response AsJsonNet <T>(this IResponseFormatter formatter, T instance) { var responseData = JsonConvert.SerializeObject(instance); return(formatter.AsText(responseData, "application/json")); }
public static Response FromJsonString(this IResponseFormatter formatter, string jsonString) { return(formatter.AsText(jsonString, "application/json")); }
public static Response AsSvg(this IResponseFormatter formatter, Svg svg) { return(formatter.AsText(svg.ToString(), "image/svg+xml")); }
public static Response AsNJson(this IResponseFormatter frmt, object o) { var n = JsonConvert.SerializeObject(o, settings); return(frmt.AsText(n)); }