I have the following code in which requestLine
is always empty and I can't figure out why. request
contains a raw HTTP request, and I want to get the first line of the request which contains the method and the URL.
boolean parseRequest(String* request)
{
int firstEOLAt = request->indexOf('\n');
if (firstEOLAt < 0)
return false;
Serial.println(firstEOLAt);
String requestLine = request->substring(0, firstEOLAt);
Serial.println(requestLine);
// ...rest of the parsing will go here...
return true;
}
The first println
returns 26 as you would expect for the string "GET /ilyen_nincs HTTP/1.1"
(25 characters long), but then requestLine
is always empty. I wonder why?