Skip to content

Commit dd08884

Browse files
committed
fixed fatal line parsing error
1 parent 6da437a commit dd08884

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/net/tootallnate/websocket/Charsetfunctions.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public static String stingAscii( byte[] bytes ) {
3333
throw new RuntimeException( e );
3434
}
3535
}
36+
37+
public static String stingAscii( byte[] bytes, int offset, int length ) {
38+
try {
39+
return new String( bytes, offset, length, "ASCII" );
40+
} catch ( UnsupportedEncodingException e ) {
41+
throw new RuntimeException( e );
42+
}
43+
}
3644

3745
public static String stingUtf8( byte[] bytes ) {
3846
try {

‎src/net/tootallnate/websocket/Draft.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static ByteBuffer readLine( ByteBuffer buf ) {
4646

4747
public static String readStringLine( ByteBuffer buf ) {
4848
ByteBuffer b = readLine( buf );
49-
return b == null ? null : Charsetfunctions.stingAscii( b.array() );
49+
return b == null ? null : Charsetfunctions.stingAscii( b.array(), 0, b.limit() );
5050
}
5151

5252
public static HandshakeBuilder translateHandshakeHttp( ByteBuffer buf ) throws InvalidHandshakeException {

0 commit comments

Comments
 (0)