Mercurial > hg > Members > kazz > WebSocket
changeset 1:4c2ddaa9b998
connection safe?
author | kazz |
---|---|
date | Sat, 22 Jan 2011 05:01:34 +0900 |
parents | 5a50d4b48bf9 |
children | d5d2ca53a832 |
files | src/IOHandler.java |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/IOHandler.java Wed Jan 19 00:16:26 2011 +0900 +++ b/src/IOHandler.java Sat Jan 22 05:01:34 2011 +0900 @@ -23,8 +23,8 @@ try { int num; if ((num = sChannel.read(buffer)) > 0) { - String str = new String(buffer.array()); - Pattern pat = Pattern.compile("((([^\n\r]+): ([^\n\r]+))|(^GET ([/A-Za-z]+) HTTP/1.1))"); + String str = new String(buffer.array(), 0, num - 8); + Pattern pat = Pattern.compile("((([^\n\r:]+): ([^\n\r]+))|(^GET ([^ \n\r]+) HTTP/1.1))"); Matcher mat = pat.matcher(str); while (mat.find()) { if (mat.group(6) != null) { @@ -98,7 +98,7 @@ private int generateResponseCodeValue(String str) { char[] ch = str.toCharArray(); - int val = 0; + long val = 0; int spNum = 0; for (char c : ch) { if (c == ' ') { @@ -108,6 +108,6 @@ val += c - '0'; } } - return val / spNum; + return (int) (val / spNum); } }