-dev:
In this environment, it is very unlikely that you can save an entire "thing" and then process it all at once. Because there is limited RAM, you will almost certainly have to process "things" as they are received, gradually accumulating only a few key pieces of information. BONUS: this approach is also faster.So I have to ask:
What is in the header that you really want?
Do you have some code that is reading this stream of bytes?
first im only starting on the ESP8266 for the first time so I am using the references as I can find them and they were using string to store the information from the stream
1)What I want is to get the HTTP requests information from when I click any of the buttons
The value in the HTTP request is created by combining values from sliders on the page.
GET /HourRed/ColVal=200 HTTP/1.1
Host: 192.168.1.50
Connection: keep-alive
User-Agent: Mozilla/5.0 (Linux; Android 8.0.0; SM-G950F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36
Save-Data: on
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: http://192.168.1.50/HourRed/ColVal=200
Accept-Encoding: gzip, deflate
Accept-Language: en-NZ,en-GB;q=0.9,en-US;q=0.8,en;q=0.7
is what is stored in the header string (or character array if i work out how to use that with the ESP) I just want the part
GET /HourRed/ColVal=200 HTTP/1.1
where 200 could be any number between 0-255
2)Yes there is a stream that gets the information
The client is reading the http request byte by byte
Ill provide a snippet of the server update function that runs while a client is connected because i'm still learning how some of it works. and don't know what parts will and will not be useful. and it will explaine it better then i could about what is going on.
void ClockServer::serverUpdate()
{
WiFiClient client = server.available(); // Listen for incoming clients
if (client) // If a new client connects,
{
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
String header;
while (client.connected()) // loop while the client's connected
{
if (client.available()) // if there's bytes to read from the client,
{
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') // if the byte is a newline character
{
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0)
{
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
Serial.println(header); //This is where I see what is in the header
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
//HTML body Code goes here
client.println("<!DOCTYPE html>");
client.println("<html>");
...
This is where all the HTML code is
there is one line that says
client.println(" <a href=\"/HourRed/\" onmouseup=\"location.href=this.href+'ColVal='+sliderHourRed.value;return false;\">");
that sends the http request
...
//END OF HTML
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else // if you got a newline, then clear currentLine
{
currentLine = "";
}
} else if (c != '\r') // if you got anything else but a carriage return character,
{
currentLine += c; // add it to the end of the currentLine
}
}
Serial.println("Client stillConnected");
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}