public void TestExtendedCharactersContentLength() { var asciiWithExtendedCharacters = ExtendedCharactersFixture.AsciiWithExtendedCharacters(); var response = Response.Of(ResponseStatus.Ok, Headers.Empty <ResponseHeader>(), asciiWithExtendedCharacters); var contentLength = int.Parse(response.HeaderValueOr(RequestHeader.ContentLength, "0")); Assert.False(contentLength == 0); Assert.True(asciiWithExtendedCharacters.Length < contentLength); Assert.Equal(Converters.TextToBytes(asciiWithExtendedCharacters).Length, contentLength); }
public static IObjectResponse Of <TR>( Response.ResponseStatus status, TR entity) => new ObjectResponse <TR>(Version.Http1_1, status, Headers.Empty <ResponseHeader>(), entity);
/// <summary> /// Answer a <see cref="Response"/> with the <see cref="ResponseStatus"/> and <paramref name="entity"/> /// with a <code>Content-Type</code> header per my <code>ContentType</code>, which may be overridden. /// </summary> /// <param name="status">The status of the response</param> /// <param name="entity">The string entity of the response</param> /// <returns><see cref="Response"/></returns> protected Response EntityResponseOf(ResponseStatus status, string entity) => EntityResponseOf(status, Headers.Empty <ResponseHeader>(), entity);