diff options
author | Simone Bordet | 2012-02-24 10:26:50 +0000 |
---|---|---|
committer | Simone Bordet | 2012-02-24 10:26:50 +0000 |
commit | 2e66e54425eaa08d9ae1f5e02ca0c9de8e14b20b (patch) | |
tree | c8d08c26cbf7f05726cd693e092a894a8ad7a854 /jetty-websocket/src | |
parent | 3a821765311b0428fbbb6a50b2cc42739af706ce (diff) | |
download | org.eclipse.jetty.project-2e66e54425eaa08d9ae1f5e02ca0c9de8e14b20b.tar.gz org.eclipse.jetty.project-2e66e54425eaa08d9ae1f5e02ca0c9de8e14b20b.tar.xz org.eclipse.jetty.project-2e66e54425eaa08d9ae1f5e02ca0c9de8e14b20b.zip |
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.
Diffstat (limited to 'jetty-websocket/src')
-rw-r--r-- | jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java index 3b5d8fd0b8..69f18c26cf 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java @@ -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); @@ -56,7 +55,7 @@ public class SafariD00 /** * Open the Socket to the destination endpoint and - * + * * @return the open java Socket. * @throws IOException */ @@ -75,7 +74,7 @@ public class SafariD00 /** * Issue an Http websocket (Draft-0) upgrade request (using an example request captured from OSX/Safari) - * + * * @throws UnsupportedEncodingException */ public void issueHandshake() throws IOException @@ -103,23 +102,22 @@ public class SafariD00 out.write(buf,0,buf.length); out.flush(); + socket.setSoTimeout(10000); + // 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) + 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 |