Hi Simone, Yes any help would be appreciated ... See my comment in code below: // ***
Thanks, -Alan
import org.eclipse.jetty.client.api.AuthenticationStore;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.util.BasicAuthentication;
import org.eclipse.jetty.client.util.BufferingResponseListener;
import java.net.URI;
/*
* Testcode driver
*/
final public class App {
public static void main(String[] args) throws Exception {
HttpClient httpClient = new HttpClient();
httpClient.start();
String url = "" href="http://localhost:8080/largefile.zip">http://localhost:8080/largefile.zip";
URI uri = new URI(url);
String realm = "MyRealm";
String u = "u1";
String p = "p1";
AuthenticationStore auth = httpClient.getAuthenticationStore();
auth.addAuthentication(new BasicAuthentication(uri, realm, u, p));
httpClient.newRequest(uri)
// Buffer response content up to 8 MiB
.send(new BufferingResponseListener(8 * 1024 * 1024)
{
@Override
public void onComplete(Result result)
{
if (!result.isFailed())
{
byte[] responseContent = getContent();
System.out.println("Success.");
} else {
System.out.println("Failed:");
}
}
});
// *** Right after httpClient.newRequest it goes here!
httpClient.stop();
}
}