Permalink
Browse files

changed new line detection

  • Loading branch information...
1 parent 9cccdea commit 7a8b241fd1ca3ea22866012b7fb90e55b34a945c @justinmclean committed Oct 6, 2011
Showing with 14 additions and 7 deletions.
  1. +14 −7 WebSocketsServerEthernet.pde
@@ -27,21 +27,28 @@ void setup()
String readLine(Client client)
{
String data;
+ boolean lineEnd = false;
- while (client.available())
+ while (!lineEnd)
{
- char c = client.read();
+ if (client.available()) {
+ char c = client.read();
- data.concat(c);
- if (c == '\n') {
- return data;
- }
+ if (c != '\n' && c != '\r') {
+ data.concat(c);
+ }
+ if (c == '\n') {
+ lineEnd = true;
+ }
+ }
}
+
+ return data;
}
// Return true is line is "blank"
boolean blankLine(String line) {
- return (line.length() == 2 && line[0] == '\r' && line[1] == '\n');
+ return (line.length() == 0);
}
// Send a standard http response header

0 comments on commit 7a8b241

Please sign in to comment.