}
HttpResponse response = null;
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
if (eeRequest.expectContinue()) {
response = this.responseFactory.newHttpResponse(
ver,
HttpStatus.SC_CONTINUE,
context);
HttpParamsLinker.link(response, this.params);
if (this.expectationVerifier != null) {
try {
this.expectationVerifier.verify(request, response, context);
} catch (HttpException ex) {
response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
HttpParamsLinker.link(request, this.params);
handleException(ex, response);
}
}
if (response.getStatusLine().getStatusCode() < 200) {
// Send 1xx response indicating the server expections
// have been met
synchronized (connState) {
connState.setResponse(response);
conn.requestOutput();
// Block until 1xx response is sent to the client
try {
for (;;) {
int currentState = connState.getOutputState();
if (currentState == ServerConnState.RESPONSE_SENT) {
break;
}
if (currentState == ServerConnState.SHUTDOWN) {
throw new InterruptedIOException("Service interrupted");
}
connState.wait();
}
} catch (InterruptedException ex) {
connState.shutdown();
return;
}
connState.resetOutput();
response = null;
}
} else {
// Discard request entity
conn.resetInput();
eeRequest.setEntity(null);
}
}
// Create a wrapper entity instead of the original one
if (eeRequest.getEntity() != null) {
eeRequest.setEntity(new ContentBufferEntity(
eeRequest.getEntity(),
connState.getInbuffer()));
}
}