Hello I am new with CloseableHttpClient and HttpPut and want to use them, because with java core HttpUrlConnection class I have to fully populate OutputStream with data, before it starts transfer to server. While my data to send size is big, this is not fits my need, because takes too much RAM. Data collection speed much less than upload speed to server, where I want to PUT data, so I want to use HttpPut with output stream. I was able to swithch from Java core class and make PUT request with CloseableHttpClient and HttpPut but only with short String data by ByteArrayEntity. When I try to PUT with OutputStream, I get no errors/exceptions, but data entity not transferred. After run I see on target server updated file, with zero length. My network Interface traffic very small and looks like no entity data transferred. Here my custom AbstractHttpEntity:
AbstractHttpEntity entity = new AbstractHttpEntity() { @Override public void writeTo(OutputStream outstream) throws IOException { for (Integer i=0; i<5000000; i++){ String dataString = i+" data string."; outstream.write(dataString.getBytes(Charset.forName("UTF-8"))); } } @Override public boolean isStreaming() { return true; } @Override public boolean isRepeatable() { return true; } @Override public long getContentLength() { return -1; } @Override public InputStream getContent() throws IOException, UnsupportedOperationException { throw new UnsupportedOperationException(); //return null; } }; In debugger I see writeTo method call and in loop writes to outstream. I also played a bit with expect continue, like: HttpPut putRequest = new HttpPut(url.toString()); RequestConfig defaultRequestConfig = RequestConfig.custom().setExpectContinueEnabled(true).build(); putRequest.setConfig(defaultRequestConfig); or putRequest.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE); But this not helps. Here also my dependencies: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.4</version> </dependency> Please help how to figure this out. Everything looks like works, but actually data not transfer. -- View this message in context: http://httpcomponents.10934.n7.nabble.com/putRequest-outputStream-tp27956.html Sent from the HttpClient-User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org