*/
private void sendRequestBody(
final HttpEntityEnclosingRequest request,
final ClientConnState connState,
final NHttpClientConnection conn) throws IOException {
HttpEntity entity = request.getEntity();
if (entity != null) {
this.executor.execute(new Runnable() {
public void run() {
try {
// Block until previous request is fully processed and
// the worker thread no longer holds the shared buffer
synchronized (connState) {
try {
for (;;) {
int currentState = connState.getOutputState();
if (!connState.isWorkerRunning()) {
break;
}
if (currentState == ServerConnState.SHUTDOWN) {
return;
}
connState.wait();
}
} catch (InterruptedException ex) {
connState.shutdown();
return;
}
connState.setWorkerRunning(true);
}
HttpEntity entity = request.getEntity();
OutputStream outstream = new ContentOutputStream(
connState.getOutbuffer());
entity.writeTo(outstream);
outstream.flush();
outstream.close();
synchronized (connState) {
connState.setWorkerRunning(false);