How do I remove the http Header?

Hello everybody,

I'm searching a solution to remove the http Header from my Display.
I found many topics about this, but nobody was using the same packages as I do.

#include <GxEPD.h>

//Display Class
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" b/w

#include GxEPD_BitmapExamples

// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold24pt7b.h>

#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

GxIO_Class io(SPI, /CS=5/ SS, /DC=/ 17, /RST=/ 16); // arbitrary selection of 17, 16
GxEPD_Class display(io, /RST=/ 16, /BUSY=/ 4); // arbitrary selection of (16), 4

#include <WiFi.h>

const char * ssid = "ssid";
const char * pswd = "pswd";

const char * site = "site";
const int port = 80;

void setup() {
Serial.begin(115200);
Serial.println();

connectWLAN(ssid, pswd);

Serial.println();

delay(2000);
display.init(115200); //enable diagnostic output on Serial

Serial.println();
Serial.println();

Serial.println("--------------------------SETUP DONE--------------------------");

Serial.println();
Serial.println();
}

void loop() {
readPage(site, port);

delay(10000);
}

void showFont(const GFXfont* f, String header)
{
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(f);
display.setCursor(0, 0);
display.println(header);
display.println();
display.println(nameofmeeting);
display.println(room);
display.println(organisator);
//display.update();
}

void connectWLAN(const char * ssid, const char * pswd)
{
Serial.println("Verbinden mit " + String(ssid));

WiFi.begin(ssid, pswd);

while (WiFi.status() != WL_CONNECTED);

Serial.println();
Serial.println("Verbunden");
Serial.print("Eigene IP Adresse: ");
Serial.println(WiFi.localIP());
}

void printPage(WiFiClient client) {
while (client.available())
{
String line = client.readStringUntil('\r');

showFont(&FreeMonoBold9pt7b,String(line), "", "", "");
display.update();

Serial.println(line);
}
}

String createGetCommand(const char * site) {
return (String)"GET / HTTP/1.1\r\n" +
"Host: " + String(site) + "\r\n" +
"Connection: close\r\n\r\n";
}

void getPage(WiFiClient client, const char * site) {
client.print(createGetCommand(site));
unsigned long timeout = millis();
while (client.available() == 0) // maximal 5 Sekunden
{
if (millis() - timeout > 5000)
{
Serial.println("*** Client Zeitüberschreitung ***");
client.stop();
return;
}
}
Serial.println();
}

void readPage(const char * site, uint8_t port)
{
Serial.println("Verbinden mit URL: " + String(site));

// TCP-Verbindung erzeugen
WiFiClient client;
if (!client.connect(site, port)) // verbinden
{
Serial.println("*** Verbindung fehlgeschlagen ***");
return; // in die nächste Runde
Serial.println("*Nächster Versuch");
}
// Verbindungsaufbau ist jetzt gestartet:
Serial.println("Verbindung steht");

getPage(client, site); // Seite holen
printPage(client); // Seite ausgeben

Serial.println("Schließen der Verbindung");

client.stop(); // Verbindung schließen
}

    String line = client.readStringUntil('\r');
 
    showFont(&FreeMonoBold9pt7b,String(line), "", "", "");

Why the f**k do you need to create ANOTHER (useless) String from the String called line?

Why do you assume that EVERYTHING you read from the client needs to be displayed?

This is only my first test for this project.... I am going to add some more options so I inserted them already.

I am going to add some more options so I inserted them already.

So, pissing away resources is built into your program from the start. Well, good luck with that stupid approach.

I only want to know how to remove the HTTP-Headers... The rest is not important for that.

maximiliankapra:
I only want to know how to remove the HTTP-Headers... The rest is not important for that.

You read a line from the client. YOU have to decide, BEFORE you display it, whether you need to display it, or not.

What criteria will you use to make that decision?

I already tried with Regular Expressions to filter the whole header but I've read that it is not possible in the Arduino IDE.

Do you have a hint for me how I can do this in another way?

I already tried with Regular Expressions to filter the whole header but I've read that it is not possible in the Arduino IDE.

There are several issues with this statement. The first is the term "whole header". You are NOT reading ALL of the server response and then deciding what to do with the whole response.

The second is that there might be a regular expression library for the Arduino, but you have provided no link to that library. Regular expression parsing is NOT trivial.

The third is that you have not even hinted at what the regular expression looks like that you want to use to parse the server response.

Finally, what is possible in the IDE and what is possible on the Arduino are two completely separate things.

It MIGHT be possible, with a suitable Arduino, to read the COMPLETE server response and then use a regular expression parser to extract only the relevant bits/discard the irrelevant bits.

But, to do that, you must define what makes a particular part of the (complete) response relevant/irrelevant, and you have, so far, been reluctant/unable to do that.