337685 java 1.5

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2843 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-03-01 22:33:16 +00:00
parent 9eadc0ccad
commit 13a46c3e9c
2 changed files with 17 additions and 4 deletions

View File

@ -14,6 +14,7 @@
package org.eclipse.jetty.websocket;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import javax.servlet.http.HttpServletRequest;
@ -32,7 +33,7 @@ import org.eclipse.jetty.util.log.Log;
public class WebSocketConnectionD06 extends AbstractConnection implements WebSocketConnection
{
private final static byte[] MAGIC="258EAFA5-E914-47DA-95CA-C5AB0DC85B11".getBytes(StringUtil.__ISO_8859_1_CHARSET);
private final static byte[] MAGIC;
private final static byte[] NORMAL_CLOSE=new byte[] { 1000/0xff, (byte)(1000%0xff) };
private final IdleCheck _idle;
private final WebSocketParser _parser;
@ -41,6 +42,18 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc
private boolean _closedIn;
private boolean _closedOut;
static
{
try
{
MAGIC="258EAFA5-E914-47DA-95CA-C5AB0DC85B11".getBytes(StringUtil.__ISO_8859_1);
}
catch (UnsupportedEncodingException e)
{
throw new RuntimeException(e);
}
}
private final WebSocketParser.FrameHandler _frameHandler= new WebSocketParser.FrameHandler()
{
private final Utf8StringBuilder _utf8 = new Utf8StringBuilder();
@ -124,7 +137,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc
{
code=buffer.array()[buffer.getIndex()]*0xff+buffer.array()[buffer.getIndex()+1];
if (buffer.length()>2)
message=new String(buffer.array(),buffer.getIndex()+2,buffer.length()-2,StringUtil.__UTF8_CHARSET);
message=new String(buffer.array(),buffer.getIndex()+2,buffer.length()-2,StringUtil.__UTF8);
}
closeIn(code,message);
break;
@ -403,7 +416,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc
}
else
{
byte[] bytes = ("xx"+(message==null?"":message)).getBytes(StringUtil.__ISO_8859_1_CHARSET);
byte[] bytes = ("xx"+(message==null?"":message)).getBytes(StringUtil.__ISO_8859_1);
bytes[0]=(byte)(code/0xff);
bytes[1]=(byte)(code%0xff);
_generator.addFrame(WebSocket.OP_CLOSE,bytes,0,bytes.length,_endp.getMaxIdleTime());

View File

@ -179,7 +179,7 @@ public class WebSocketMessageD06Test
output.write(0xff);
output.write(0x84^0xff);
output.write(0x0f^0xff);
byte[] bytes="this is an echo".getBytes(StringUtil.__ISO_8859_1_CHARSET);
byte[] bytes="this is an echo".getBytes(StringUtil.__ISO_8859_1);
for (int i=0;i<bytes.length;i++)
output.write(bytes[i]^0xff);
output.flush();