I'm writing a utility that will retrieve some metadata about swf (flash) files and I'd like to use httpclient to read the data but I want clarity on the necessity to read the entire stream.
The information I need is all in the first few bytes of the file, and the files could potentially be quite large so I don't want to read them in their entirety. I'd like to just read what I need and then close the connection. Here's a little test snippet, note that SWFInfo is closing the input stream on the response entity: public static void main(String[] args) throws Exception { CloseableHttpClient client = buildCloseableClient(); HttpGet get = new HttpGet("http://localhost/Cat.swf"); for (int i = 0; i < 10000; i++) { try (CloseableHttpResponse response = client.execute(get)) { SWFInfo info = SWFInfo.getInfo(response.getEntity().getContent()); System.out.println(i + ": " + info.width + "," + info.height); } } } This test executes successfully, suggesting that it's OK but I want to double check that I won't be causing any types of resource usage problems. Note that we're using HttpClient in other parts of our application, but those are pooled connections that are constructed differently. Thanks, Dan