}
return post;
}
public void handleResponse(final HttpResponse response, final HttpContext context) {
NHttpConnection conn = (NHttpConnection) context.getAttribute(
ExecutionContext.HTTP_CONNECTION);
int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
i++;
context.setAttribute("RES-COUNT", Integer.valueOf(i));
HttpEntity entity = response.getEntity();
if (entity != null) {
try {
// Simulate slow response handling in order to cause the
// internal content buffer to fill up, forcing the
// protocol handler to throttle input rate
InputStream instream = entity.getContent();
byte[] tmp = new byte[2048];
while(instream.read(tmp) != -1) {
Thread.sleep(1);
}
instream.close();
} catch (InterruptedException ex) {
requestCount.abort();
return;
} catch (IOException ex) {
requestCount.abort();
return;
}
}
requestCount.decrement();
if (i < reqNo) {
conn.requestInput();
}
}
};