To make Blocking Send call in Chunked Transfer Support

17 views
Skip to first unread message

Rajat Saxena

unread,
Jan 4, 2018, 4:16:10 AM1/4/18
to Nginx-Clojure
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);
}


Yuexiang Zhang

unread,
Jan 18, 2018, 8:55:58 AM1/18/18
to Rajat Saxena, Nginx-Clojure

--
You received this message because you are subscribed to the Google Groups "Nginx-Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nginx-clojure+unsubscribe@googlegroups.com.
To post to this group, send email to nginx-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nginx-clojure/ff265430-15f0-45c2-a32c-349225d83e01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages