protected void processHttp(HttpRequestHeader requestHeader, boolean isSecure) throws IOException {
HttpBody reqBody = null;
boolean isFirstRequest = true;
HttpMessage msg = null;
if (isRecursive(requestHeader)) {
throw new IOException("Recursive request to proxy itself stopped.");
}
// reduce socket timeout after first read
inSocket.setSoTimeout(2500);
do {
if (isFirstRequest) {
isFirstRequest = false;
} else {
try {
requestHeader = httpIn.readRequestHeader(isSecure);
} catch (SocketTimeoutException e) {
return;
}
}
msg = new HttpMessage();
msg.setRequestHeader(requestHeader);
if (msg.getRequestHeader().getContentLength() > 0) {
reqBody = httpIn.readBody(requestHeader);
msg.setRequestBody(reqBody);
}
modifyHeader(msg);
if (isProcessCache(msg)) {
continue;
}
// System.out.println("send required: " + msg.getRequestHeader().getURI().toString());
if (parentServer.isSerialize()) {
semaphore = semaphoreSingleton;
} else {
semaphore = this;
}
synchronized (semaphore) {
notifyListenerRequestSend(msg);
try {
// bug occur where response cannot be processed by various listener
// first so streaming feature was disabled
// getHttpSender().sendAndReceive(msg, httpOut, buffer);
getHttpSender().sendAndReceive(msg);
notifyListenerResponseReceive(msg);
// write out response header and body
httpOut.write(msg.getResponseHeader());
httpOut.flush();
if (msg.getResponseBody().length() > 0) {
httpOut.write(msg.getResponseBody().getBytes());
httpOut.flush();
}
// notifyWrittenToForwardProxy();