Read input stream of HttpUrlConnection

S

SPG

Hi,

One of our servers responds to an HTTP request by streaming text through the
response. It send a header back that specifies the content-length = 0.

Unfortunately the HttpUrlConnection determines that there is no data to read
and closes the stream.

I am sure there must be a way around this.. Any ideas?

Steve
 
R

Rogan Dawes

SPG said:
Hi,

One of our servers responds to an HTTP request by streaming text through the
response. It send a header back that specifies the content-length = 0.

Unfortunately the HttpUrlConnection determines that there is no data to read
and closes the stream.

I am sure there must be a way around this.. Any ideas?

Steve

Hmmm. That's a tricky one. Let me see.

Oh, yes.

DON'T set the Content-Length header to 0 at the server! It is not
surprising that the UrlConnection terminates the connection if the
server says that it has no data.

If you have to stream data, perhaps a chunked encoded stream is a better
idea?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,310
Latest member
FaustoMont

Latest Threads

Top