use of com.google.api.client.testing.http.apache.MockHttpClient in project google-http-java-client by googleapis.
the class ApacheHttpRequestTest method testContentLengthSet.
@Test
public void testContentLengthSet() throws Exception {
HttpExtensionMethod base = new HttpExtensionMethod("POST", "http://www.google.com");
ApacheHttpRequest request = new ApacheHttpRequest(new MockHttpClient(), base);
HttpContent content = new ByteArrayContent("text/plain", "sample".getBytes(StandardCharsets.UTF_8));
request.setStreamingContent(content);
request.setContentLength(content.getLength());
request.execute();
assertFalse(base.getEntity().isChunked());
assertEquals(6, base.getEntity().getContentLength());
}
Aggregations