370387 - SafariWebsocketDraft0Test failure during build.

The reason for the failure of this test was that a BufferedReader was used to read the header lines.
However, the buffered reader may have read and buffered also the hixie bytes and subsequently,
when the test was trying to read the hixie bytes directly from the input stream (and not from the
buffered reader), the read was timing out.
Fixed by always using the input stream to read the header and hixie bytes.
This commit is contained in:
Simone Bordet 2012-02-24 11:26:50 +01:00
parent 3a82176531
commit 2e66e54425
1 changed files with 17 additions and 19 deletions

View File

@ -15,9 +15,6 @@
*******************************************************************************/
package org.eclipse.jetty.websocket.helper;
import static org.hamcrest.Matchers.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -35,6 +32,8 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.log.StdErrLog;
import org.junit.Assert;
import static org.hamcrest.Matchers.is;
public class SafariD00
{
private static final Logger LOG = Log.getLogger(SafariD00.class);
@ -103,23 +102,22 @@ public class SafariD00
out.write(buf,0,buf.length);
out.flush();
// Read HTTP 101 Upgrade / Handshake Response
InputStreamReader reader = new InputStreamReader(in);
BufferedReader br = new BufferedReader(reader);
socket.setSoTimeout(10000);
LOG.debug("Reading http header");
boolean foundEnd = false;
String line;
while (!foundEnd)
// Read HTTP 101 Upgrade / Handshake Response
InputStreamReader reader = new InputStreamReader(in);
LOG.debug("Reading http headers");
int crlfs = 0;
while (true)
{
line = br.readLine();
// System.out.printf("RESP: %s%n",line);
if (line.length() == 0)
{
foundEnd = true;
}
int read = in.read();
if (read == '\r' || read == '\n')
++crlfs;
else
crlfs = 0;
if (crlfs == 4)
break;
}
// Read expected handshake hixie bytes