hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robyp1 <rob...@hotmail.com>
Subject anaging streaming http connection
Date Sun, 13 Feb 2011 15:48:44 GMT

hi,

i have a problem.. I try to read from a web server that stream video and
audio content media : flv type
i make http request using HttpGet class from org.apache.http.client.methods
to this server url like this :

HttpGet get = new HttpGet(url)
HttpResponse response = myHttpClientObject.execute(get);

but when i try to read content in a buffer like this:

entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();

System.out.println("**Entity content-length " + entity.getContentLength());
//it is 2147483647!

byte[] b = EntityUtils.toByteArray(entity); <-- using this utility with a
dinamic resizing array of bytes

i get a
**Entity content-length 2147483647
Exception in thread "pool-1-thread-3" java.lang.OutOfMemoryError: Java heap
space
java.lang.OutOfMemoryError: Java heap space
at org.apache.http.util.ByteArrayBuffer.<init>(ByteArrayBuffer.java:55)
at org.apache.http.util.EntityUtils.toByteArray(EntityUtils.java:96)

beacuse the constructor of ByteArrayBuffer creat a new byte[2147483647]
array

what is wrong..i suppose that because my resource is not static i must use a
chunk mode, really?? but how i can use it with HttpGet??.. i think HttpPot
is not supported by server beacuse
i get a http page with a forbidden message(you're not authorized). But using
a HttpGet and read by a inputStreamer (not the right choice with 8 bit
content type) i get
the streaming source:

//StringBuffer httpResponse = new StringBuffer();
// input = new BufferedReader(new InputStreamReader(instream));
// String resp = "null";
// while (resp != null && !(resp).equals("")) {
// log.log(Level.INFO, resp);
// resp = input.readLine();
// httpResponse.append(resp);
// }

I have to get this output and send it to a vlc player or any kind of flv
stream player ..

thank you

Bye
Roby
-- 
View this message in context: http://old.nabble.com/anaging-streaming-http-connection-tp30915038p30915038.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message