Question

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?

Was it helpful?

Solution

Try:

HttpHeaders.setContentLength(response, 0l);
response.setContent(null); 

Also make sure that your browser is not loading the content from the local cache.

I'm not sure that you can use LittleProxy to intercept and change the response like that... Although this thread suggests that you can do so using a HttpFilter (check this test code for the basic structure). Otherwise you will have to dig into Little Proxy source code for further customization.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top