Hi,
I am a First time user of Nginx Clojure.
I am using higher version API of Nginx NginxHttpServerChannel.sendHeader/send to send the Data from the TCP channel.
Currently It is a Non-Blocking Call.
I want to make it a Blocking Call so that if the Client is not reading the Data, Nginx Should not write/send the Data into the Channel.
Please help in making this call as Blocking Call, so that if the Client is not reading the data, Nginx can stop sending the data.
here is the Code snippet from my Class:
NginxHttpServerChannel serverChannel = req.hijack(false);
private void doWriteWithNginxIntercept(NginxHttpServerChannel serverChannel, boolean isLastByte, boolean isFileWritten) throws IOException {
ContentPullContext contentPullContext = (ContentPullContext) serverChannel.getContext();
/* Let's send the content now in chunks*/
do {
contentPullContext.getTemporaryBuffer().clear();
HackUtils.putBuffer(contentPullContext.getTemporaryBuffer(), contentPullContext.getContentBuffer());
if((contentPullContext.getContentBuffer().remaining() == 0) && !(isFileWritten)){
isLastByte = true;
}
contentPullContext.getTemporaryBuffer().flip();
serverChannel.send(contentPullContext.getTemporaryBuffer(), true, isLastByte);
LOG.info("Bytes Written to the Channel={}", contentPullContext.getContentBuffer().position());
if (isLastByte){
LOG.info("Channel Closed");
break;
}
if(contentPullContext.getContentBuffer().remaining() == 0){
break;
}
} while (true);
}