Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Created November 26, 2010 19:01
Show Gist options
  • Save jfarcand/717095 to your computer and use it in GitHub Desktop.
Save jfarcand/717095 to your computer and use it in GitHub Desktop.
@Test(groups = "standalone")
public void basicDefaultTest() throws Throwable {
AsyncHttpClientConfig client = new AsyncHttpClientConfig.Builder().setResumableDownload(true).build();
AsyncHttpClient c = new AsyncHttpClient(client);
final RandomAccessFile file = new RandomAccessFile("800m.avi", "rw");
Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(new AsyncCompletionHandlerBase(){
private long byteTransferred = 0;
/* @Override */
public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception {
file.seek(byteTransferred);
file.write(content.getBodyPartBytes());
byteTransferred += content.getBodyPartBytes().length;
return STATE.CONTINUE;
}
}).get();
assertEquals(r.getStatusCode(), 200);
file.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment