/// <summary> /// Specifies the body returned as part of the HTTP response. /// </summary> /// <param name="response">The <see cref="T:Stumps.BasicHttpResponse" /> that returns in response to an HTTP request.</param> /// <param name="body">The value returned as body of the HTTP response.</param> /// <returns>The calling <see cref="T:Stumps.BasicHttpResponse"/>.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="response"/> is <c>null</c>.</exception> public static BasicHttpResponse WithBody(this BasicHttpResponse response, string body) { if (response == null) { throw new ArgumentNullException("response"); } response.ClearBody(); response.AppendToBody(body); return response; }
/// <summary> /// Specifies the body returned as part of the HTTP response. /// </summary> /// <param name="response">The <see cref="T:Stumps.BasicHttpResponse"/> that returns in response to an HTTP request.</param> /// <param name="path">The path to the file that contains the HTTP response.</param> /// <returns>The calling <see cref="T:Stumps.BasicHttpResponse"/>.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="response"/> is <c>null</c>.</exception> public static BasicHttpResponse WithFile(this BasicHttpResponse response, string path) { if (response == null) { throw new ArgumentNullException("response"); } var buffer = File.ReadAllBytes(path); response.ClearBody(); response.AppendToBody(buffer); var mimeType = MimeMapping.GetMimeMapping(path); response.Headers["Content-Type"] = mimeType; return response; }