public void ResolvedServiceReadRequestMissingEncoding() { ServiceCollection services = new ServiceCollection(); services .WithHostFormat(new JsonFormat()) .WithService("Test", "/") .WithEndpoint("{action}") .Post<Payload>((Payload p) => { }); byte[] encodedPayload; using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes("{\"date\":\"2012-09-22T18:46:00Z\",\"number\":42,\"text\":\"Hello, world!\"}"))) { using (MemoryStream outputStream = new MemoryStream()) { using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress)) { stream.CopyTo(compressionStream); } encodedPayload = outputStream.ToArray(); } } ResolvedService service = new ServiceResolver(services).Find(MethodType.Post, "foo"); using (RequestMessage request = new RequestMessage<Payload>(service.Name, service.RouteValues, new Uri("http://example.com/foo"))) { request.InputStream.Write(encodedPayload, 0, encodedPayload.Length); request.InputStream.Position = 0; request.SetEncodingFilter(EncodingType.Parse("gzip"), new GzipDeflateEncoding()); ReadRequestResult result = service.ReadRequest(request, encodedPayload.Length, "gzip", "application/json", request.InputStream); Assert.IsNotNull(result); Assert.IsFalse(result.Success); Assert.IsNull(result.Exception); Assert.AreEqual(StatusCode.UnsupportedMediaType, result.StatusCode); Assert.IsNull(result.RequestObject); } }