>      while((currentLine = in.readLine()) != null){
> 
> My problem is this: the readLine method hangs. All the header lines are
> received and stored fine but readLine() never returns. Looking into it, one
> book (old, from 1999) I read said this is a bug in the readLine() method and
> that the problem is that it is looking for "\r\n" but apparently is only
> getting "\r" when reading over the network.

well, even if it only got \r, that would still be valid for readLine:

http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html#readLine()

However, reading an HTTP request with readLine calls is generally a
bad idea, because there's nothing in the spec forcing things to be
lines.  If you do an HTTP POST operation, you could get a
Content-length header of, say, 16 and then you should read 16 bytes
after the \r\n\r\n that will separate the headers from the body of the
HTTP request.

Your loop should stop when readLine's contents are an empty String as
well, since that means you just read the empty line between the
headers and the body.  At that point, look back in your HashMap for
the Content-length (btw, you'll likely wanna force lower case on the
headers, the spec doesn't enforce case on header names IIRC) then read
that many bytes.  Course, BufferedReader's are character-oriented
devices, not byte-oriented, so that's a different issue :)

Anyway, just a guess.  The best tools for tracking down what's going
on for such cases tend to be (IMHO) log4j (or an equiv. logging
package) and Ethereal for seeing what's going over the wire - it's a
great way to see if the assumptions your code makes about the
formation of HTTP requests are valid :)

    http://www.ethereal.com/

Good luck!

James
-- 
James Manning <http://www.sublogic.com/james/>
GPG Key fingerprint = B913 2FBD 14A9 CE18 B2B7  9C8E A0BF B026 EEBB F6E4

_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to