EDIT: Using Arduino MEGA 2560, latest verisons of all used libraries, Arduino IDE 1.8.3
I've been working on the code below for quite a while and I'm having trouble with it.
Until the Arduino starts making NTP requests, everything works well, but as soon as NTP requests have started, the header reading code doesn't loop, it goes straight through it, as if the client disconnected after one cycle only.
The next code worked well but time wasn't accurate since I used the millis() function.
You clearly failed to read the stickies at the top of the forum. Posting your question at the same place you post your code is expected. You didn't post your code here (like you should have), so why is your question here?
but as soon as NTP requests have started, the header reading code doesn't loop, it goes straight through it, as if the client disconnected after one cycle only
A bunch of useless hand-waving. It is a pronoun with no referent, in either place.
PaulS:
You clearly failed to read the stickies at the top of the forum. Posting your question at the same place you post your code is expected. You didn't post your code here (like you should have), so why is your question here?
Well I tried but the code was too heavy (9000 characters limit on the forum).
I don't understand why it doesn't worked when NTP requests started as it worked just fine for the one without...
PaulS:
The 9000 character limit does NOT apply to attachments. The post that you should have read explained that.
I read it but I was having my lunch far from my PC meaning I couldn't access the .ino file. I uploaded it to GitHub before leaving to try to resolve the error by myself while eating. Since I didn't understand where the error could be I made this post from my smartphone.
You may have a SRAM problem. I highly recommend ditching the String data type and use character arrays instead.
To check SRAM, add this function and call it in your code.
int freeRam() {
 extern int __heap_start,*__brkval;
 int v;
 return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);Â
}
// and call it like this:
 Serial.print(F("SRAM = "));
 Serial.println(freeRam());
To save SRAM, use the F() function on your client.print calls.
I'm going to get rid of that data type when I'll make the rework of my code. I was talking about the F() function.
e.g
client.println(F("HTTP/1.1 200 OK"));
     client.println(F("Content-Type: text/html"));
     client.println(F("Refresh: 600"));
     client.println();
     client.println(F("<!DOCTYPE HTML>"));
     client.println(F("<html>"));
     client.println(F("<h1>Rapport de consommation</h1>"));
     client.println(F("<hr />"));
or
client.println(("HTTP/1.1 200 OK"));
     client.println(("Content-Type: text/html"));
     client.println(("Refresh: 600"));
     client.println();
     client.println(("<!DOCTYPE HTML>"));
     client.println(("<html>"));
     client.println(("<h1>Rapport de consommation</h1>"));
     client.println(F("<hr />"));
Well now all constant Strings are packed up in the flash memory using F() and I have only one String in the SRAM, but the bug is still here...
It seems like the HttpHeader is updated when the NTP requests begin but the program gets only the first character as the monitor reads "GClient diconnected" (instead of a normal "GET ..." and "Client disconnected" after all the client infos).