Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Created November 30, 2010 16:28
Show Gist options
  • Select an option

  • Save jfarcand/721925 to your computer and use it in GitHub Desktop.

Select an option

Save jfarcand/721925 to your computer and use it in GitHub Desktop.
@Test(groups = "standalone", enabled = false)
public void basicDefaultTest() throws Throwable {
AsyncHttpClient c = new AsyncHttpClient();
final RandomAccessFile file = new RandomAccessFile("shrek1.avi", "rw");
Response r = c.prepareGet("http://192.168.2.106:8081/shrek1.AVI")
.setRangeHeaderValue(file.length())
.execute(new AsyncCompletionHandlerBase() {
/* @Override */
public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception {
file.seek(file.length());
file.write(content.getBodyPartBytes());
return STATE.CONTINUE;
}
}).get();
assertEquals(r.getStatusCode(), 206);
file.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment