Blog

Java: Writing an XML HTTP Server.

13 February 2009
What am I doing? Rewriting the wheel!
Why is it that Java (BufferedReader(InputStreamReader(InputStream))) reads everything in my HTTP POST request fine up until the actual POST BODY?!

It only reads the POST BODY once PHP has timed out. :(
Well, in relation to my last journal on Harmonia_Game_Engine (which I forgot to tag...), I'll make a note to remember.

Don't use BufferedReader if dealing with InputStreams; use StringBuffer.

But why? You may think the BufferedReader's readLine() method is good, because it reads you a line (yep, no parsing of ints to chars), but when it comes to the last line in your stream, it doesnt return -1.

So in revision, don't check for -1 if you want to break out of a 'read input stream loop', use an \"end of stream\" set of characters or equivilent.

Share:
Share on Facebook
Tags: