示例#1
0
        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);
        }
示例#2
0
 public static IObjectResponse Of <TR>(
     Response.ResponseStatus status,
     TR entity)
 => new ObjectResponse <TR>(Version.Http1_1, status, Headers.Empty <ResponseHeader>(), entity);
示例#3
0
 /// <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);