Created
November 30, 2010 13:18
-
-
Save jfarcand/721658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test(groups = "standalone", enabled = false) | |
public void basicDefaultTest() throws Throwable { | |
AsyncHttpClientConfig client = new AsyncHttpClientConfig.Builder().setResumableDownload(true).build(); | |
AsyncHttpClient c = new AsyncHttpClient(client); | |
final RandomAccessFile file = new RandomAccessFile("shrek1.avi", "rw"); | |
Response r = c.prepareGet("http://192.168.2.106:8081/shrek1.AVI") | |
.setHeader("Range", "bytes=" + 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(), 200); | |
file.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment