If the readLine method does not return, to me that suggests the possibility that it is not reaching the end of the stream, that it is blocked waiting for input. Given what I know about HTTP (not a lot) in HTTP 1.0 the browser closed the stream after it was done writing a given GET or POST. But in HTTP 1.1 your browser may be leave the stream open. It signals the end of a given GET or POST with a special sequence of characters, for which you need scan in your code.

So, while you are waiting for the browser to close the stream, maybe it is waiting for you to say some HTTP to it.

Dev Brown wrote:
Here's a code snippet:

Note: "in" is a BufferedReader reading an HTTP request from a browser via a
socket. "HeaderElements" is a HashMap.

int colonIndex = 0;
boolean initialLine = true;
String currentLine;
try {
     while((currentLine = in.readLine()) != null){
         if(initialLine){//special case
             parseInitialRequestLine(currentLine);
             initialLine = false;
         }
         else{
             if((colonIndex = currentLine.indexOf(":")) != -1){
                 headerElements.put(currentLine.substring(0, colonIndex),
                    currentLine.substring(colonIndex+2));//the key, value

             }
         }//end else
     }//end while
}

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. Does anyone know if this really
is still a bug or am I doing something wrong? If the former, what workaround
would you suggest, read() character?

Thanks,
Dev





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

Reply via email to