Skip to content

Commit

Permalink
changed new line detection
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmclean committed Oct 6, 2011
1 parent 9cccdea commit 7a8b241
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions WebSocketsServerEthernet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a8b241

Please sign in to comment.