* @throws Exception
*/
@Test
public void testContentLength() throws Exception
{
ResteasyClient client = new ResteasyClientBuilder().build();
{
WebTarget target = client.target(TestPortProvider.generateURL("/text"));
Response response = target.request().get();
Assert.assertEquals("HELLO WORLD", response.readEntity(String.class));
String cl = response.getHeaderString("Content-Length");
if (cl != null)
{
// make sure the content length is greater than 11 because this will be a gzipped encoding
Assert.assertTrue(response.getLength() > 11);
}
}
{
WebTarget target = client.target(TestPortProvider.generateURL("/bytes"));
Response response = target.request().acceptEncoding("gzip").get();
String cl = response.getHeaderString("Content-Length");
if (cl != null)
{
// make sure the content length is greater than 11 because this will be a gzipped encoding
int i = response.getLength();
System.out.println("***");
System.out.println("Content-Length: " + i);
System.out.println("***");
Assert.assertTrue(i > 11);
}
Assert.assertEquals("HELLO WORLD", response.readEntity(String.class));
}
client.close();
}