if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity();
byte[] data = EntityUtils.toByteArray(incoming);
ByteArrayEntity outgoing = new ByteArrayEntity(data);
outgoing.setChunked(false);
response.setEntity(outgoing);
} else {
StringEntity outgoing = new StringEntity("No content");
response.setEntity(outgoing);
}
}
};
// Set protocol level to HTTP/1.0
this.client.getParams().setParameter(
CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
public void initalizeContext(final HttpContext context, final Object attachment) {
context.setAttribute("LIST", (ByteSequence) attachment);
context.setAttribute("REQ-COUNT", new Integer(0));
context.setAttribute("RES-COUNT", new Integer(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[] bytes = requestData.getBytes(i);
ByteArrayEntity outgoing = new ByteArrayEntity(bytes);
post.setEntity(outgoing);
context.setAttribute("REQ-COUNT", new Integer(i + 1));
}
return post;