Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:38:34+00:00 2026-05-13T21:38:34+00:00

I am currently trying to stream content out to the web after a trans-coding

  • 0

I am currently trying to stream content out to the web after a trans-coding process. This usually works fine by writing binary out to my web stream, but some browsers (specifically IE7, IE8) do not like not having the Content-Length defined in the HTTP header. I believe that “valid” headers are supposed to have this set.

What is the proper way to stream content to the web when you have an unknown Content-Length? The trans-coding process can take awhile, so I want to start streaming it out as it completes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:38:34+00:00Added an answer on May 13, 2026 at 9:38 pm

    Try sending them in chunks along with Transfer-Encoding: chunked. More details in wikipedia.

    Update as per the comments, here’s an example how a “ChunkedOutputStream” in Java may look like:

    package com.stackoverflow.q2395192;
    
    import java.io.IOException;
    import java.io.OutputStream;
    
    public class ChunkedOutputStream extends OutputStream {
    
        private static final byte[] CRLF = "\r\n".getBytes();
        private OutputStream output = null;
    
        public ChunkedOutputStream(OutputStream output) {
            this.output = output;
        }
    
        @Override
        public void write(int i) throws IOException {
            write(new byte[] { (byte) i }, 0, 1);
        }
    
        @Override
        public void write(byte[] b, int offset, int length) throws IOException {
            writeHeader(length);
            output.write(CRLF, 0, CRLF.length);
            output.write(b, offset, length);
            output.write(CRLF, 0, CRLF.length);
        }
    
        @Override
        public void flush() throws IOException {
            output.flush();
        }
    
        @Override
        public void close() throws IOException {
            writeHeader(0);
            output.write(CRLF, 0, CRLF.length);
            output.write(CRLF, 0, CRLF.length);
            output.close();
        }
    
        private void writeHeader(int length) throws IOException {
            byte[] header = Integer.toHexString(length).getBytes();
            output.write(header, 0, header.length);
        }
    
    }
    

    …which can basically be used as:

    OutputStream output = new ChunkedOutputStream(response.getOutputStream());
    output.write(....);
    

    You see in the source, every chunk of data exist of a header which represents the length of data in hex, a CRLF, the actual data and a CRLF. The end of the stream is represented by a header denoting a 0 length and two CRLFs.

    Note: despite the example, you actually do not need it in a JSP/Servlet based webapplication. Whenever the content length is not set on a response, the webcontainer will automatically transfer them in chunks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to figure out how to save the content from a
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so
I'm currently trying to pass a mono threaded program to multithread. This software do
I currently trying to find a solution, how to ensure that a test fails
I'm currently trying to read in an XML file, make some minor changes (alter
I'm currently trying to build a personal website to create a presence on the
I'm currently trying to port a SIP stack library (pjSIP) to the PSP Console
I'm currently trying to get into the Java EE development with the Spring framework.
My team is currently trying to automate the deployment of our .Net and PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.