For an experiment purpose where I need to drop a specific content (audio data) coming from youtube in a HTTP response message, I am using below code.
Right now I am testing with specific video, and I know the size of the content. Ran some test without this code and captured the size variable.
if (contType.equals("text/plain") && contLen > 200000 && contLen < 300000) {
outputFileName = projRoot + File.separator + folder + File.separator + "v_" + seqNum + "_" + String.valueOf(ranNum);
log.debug("This is AUDIO data received, and dropping it off");
response.setHeader("Content-Length", 0);
response.getContent().clear();
return true;
}
However when I run this program I see the log getting printed; however, it does not really drop the content. I see client (browser flash player) is still able to download the content, and this time with different size. The video is played with both visual and audio.
What is the correct way to drop off the content before it reaches the client? Am I missing on something here?