if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity();
byte[] data = EntityUtils.toByteArray(incoming);
NByteArrayEntity outgoing = new NByteArrayEntity(data);
outgoing.setChunked(false);
response.setEntity(outgoing);
} else {
NStringEntity outgoing = new NStringEntity("No content");
response.setEntity(outgoing);
}
}
};
HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
public void initalizeContext(final HttpContext context, final Object attachment) {
context.setAttribute("LIST", attachment);
context.setAttribute("REQ-COUNT", Integer.valueOf(0));
context.setAttribute("RES-COUNT", Integer.valueOf(0));
}
public void finalizeContext(final HttpContext context) {
}
public HttpRequest submitRequest(final HttpContext context) {
int i = ((Integer) context.getAttribute("REQ-COUNT")).intValue();
BasicHttpEntityEnclosingRequest post = null;
if (i < reqNo) {
post = new BasicHttpEntityEnclosingRequest("POST", "/?" + i);
byte[] data = requestData.getBytes(i);
NByteArrayEntity outgoing = new NByteArrayEntity(data);
post.setEntity(outgoing);
context.setAttribute("REQ-COUNT", Integer.valueOf(i + 1));
}
return post;