On 17.10.03 01:31 Uhr, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Message: 5 > Date: Fri, 17 Oct 2003 01:31:41 -0400 > From: James Manning <[EMAIL PROTECTED]> > Subject: [Juglist] Re: Hanging with BufferedReader > To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=us-ascii Hi James! > well, even if it only got \r, that would still be valid for readLine: *** Yeah, that is what I thought when I read the API before too. The book I mentioned before was O'Reilly's "Java I/O" by Harold in which he writes: "The problem is that if readLine see a carriage return, it waits to see if the next character is a linefeed before returning. If a network client or server on the other end of the connection is only sending carriage returns to end lines, there's a possibility that the remote client or server may wait for a response to the line it sent before sending any more data." If I hit stop on the browser, readLine returns (without any socket exception) or if I loop until a blank line is found. The value of currentLine would therefore seem to be blank, which goes along with the HTTP protocol that states the header list is terminated by an empty line. > 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. *** Yeah, I understand that. I only wanted to read the request headers as lines since according to the HTTP protocol, all information in a request other than data/body are lines terminated by "\r\n" (http://www.w3.org/Protocols/HTTP/Body.html). I picked GET specifically as a test case because it does not have any data associated with it, other than a possible query string. > 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. *** Thanks! I'm glad you pointed that out and I added it to the if/statement. Still, I feel readLine should be returning... > At that point, look back in your HashMap for > the Content-length (btw, you'll likely wanna force lower case on the > headers, *** Another good point. > Course, BufferedReader's are character-oriented > devices, not byte-oriented, so that's a different issue :) *** Yeah, been thinking about that because at some point, I will want to hand POST requests. > 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 *** Any way to get ethereal without doing the whole Fink thing? I'm on OS X and have heard some bad things about Fink on it (i.e. kernal panics). Thanks for your help James! _______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
