On Wed, 2006-05-24 at 16:14 +0100, David Harrigan wrote: > Hi, > > I'm trying to process an inputstream that is chunked. Due > to project constraints, I can't use HttpClient, but instead > I have to work directly with a socket. >
Do not use HttpClient 3.x. Its API is simply not well suited for that. Consider using HttpCore [1]. Even though it is still ALPHA I think you will be much better off. [1]http://jakarta.apache.org/httpcomponents/http-core/index.html > I'm wrapping the inputstream like this: > > BufferedReader in = new BufferedReader(new InputStreamReader(new > ChunkedInputStream(inputStream))) > > where ChunkedInputStream is from > > org.apache.commons.httpclient.ChunkedInputStream > > I fire off my http request and a chunked response comes back (verified > using > Ethereal) > > Meanwhile, I'm calling: > > while(!in.ready()) { > try { > Thread.sleep(50); > } catch (InterruptedException e) { > } > } > ... > ... other lines of code to deal with parsing the data coming back > ... > > The problem is that in.ready() never ever returns true! > Well, the sad truth is that in lots of cases InputStream#available() and Reader#ready() are unreliable or broken, plain and simple, so their use is generally discouraged. ChunkedInputStream#available() simply always returns 0 Oleg > Am I doing something terribly wrong? > > (btw, I know the while would loop forever, but I've stripped out the > code that kills the loop if a condition is reached...) > > I do hope someone can help. > > Thanks! > > -=david=- > > > This email and the files transmitted with it are meant solely for the use of > the individual addressee(s) named above. They may contain confidential and/or > legally privileged information. If you are not the addressee(s) or > responsible for delivery of the message to the addressee(s), please delete it > from your system and contact the sender right away. The opinions, conclusions > and other information in this message which do not relate to the official > business of Wanadoo UK plc are not necessarily endorsed by it. Wanadoo UK plc > has taken steps to ensure that this email and any attachments are virus-free, > but it remains your responsibility to confirm and ensure this. > > Wanadoo UK plc is a subsidiary of France Telecom SA. Our registered office is > at: Verulam Point, Station Way, St. Albans, Herts, AL1 5HE, and we are > registered in England and Wales, as Company No. 3014367 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
