@@ -18,20 +18,25 @@ ArduinoHttpServer::AbstractStreamHttpReply::AbstractStreamHttpReply(Stream& stre
1818
1919}
2020
21- void ArduinoHttpServer::AbstractStreamHttpReply::sendHeader (size_t size)
22- {
21+ void ArduinoHttpServer::AbstractStreamHttpReply::sendHeader (
22+ size_t size, const String& title) {
2323 // Read away remaining bytes.
24- while (getStream ().read ()>=0 );
24+ while (getStream ().read () >= 0 ) {
25+ }
2526
26- getStream ().print ( AHS_F (" HTTP/1.1 " ) );
27- getStream ().print ( getCode () + " " );
28- getStream ().print ( AHS_F (" Connection: close\r\n " ) );
29- if (size > 0 )
30- {
31- getStream ().print ( AHS_F (" Content-Length: " ) ); getStream ().print (size); getStream ().print ( AHS_F (" \r\n " ) );
27+ getStream ().print (AHS_F (" HTTP/1.1 " ));
28+ getStream ().print (getCode () + " " );
29+ getStream ().print (title + " \r\n " );
30+ getStream ().print (AHS_F (" Connection: keep-alive\r\n " ));
31+ if (size > 0 ) {
32+ getStream ().print (AHS_F (" Content-Length: " ));
33+ getStream ().print (size);
34+ getStream ().print (AHS_F (" \r\n " ));
3235 }
33- getStream ().print ( AHS_F (" Content-Type: " ) ); getStream ().print ( m_contentType ); getStream ().print ( AHS_F (" \r\n " ) );
34- getStream ().print ( AHS_F (" \r\n " ) );
36+ getStream ().print (AHS_F (" Content-Type: " ));
37+ getStream ().print (m_contentType);
38+ getStream ().print (AHS_F (" \r\n " ));
39+ getStream ().print (AHS_F (" \r\n " ));
3540}
3641
3742// ------------------------------------------------------------------------------
@@ -40,14 +45,16 @@ void ArduinoHttpServer::AbstractStreamHttpReply::sendHeader(size_t size)
4045void ArduinoHttpServer::AbstractStreamHttpReply::send (const String& data, const String& title)
4146{
4247 DEBUG_ARDUINO_HTTP_SERVER_PRINT (" Printing Reply ... " );
43- AbstractStreamHttpReply::sendHeader (data.length ());
48+ AbstractStreamHttpReply::sendHeader (data.length (), title );
4449 getStream ().print ( data ); getStream ().print ( AHS_F (" \r\n " ) );
4550 DEBUG_ARDUINO_HTTP_SERVER_PRINTLN (" done." );
4651}
4752
48- void ArduinoHttpServer::AbstractStreamHttpReply::send (const uint8_t * buf, const size_t size) {
53+ void ArduinoHttpServer::AbstractStreamHttpReply::send (const uint8_t * buf,
54+ const size_t size,
55+ const String& title) {
4956 DEBUG_ARDUINO_HTTP_SERVER_PRINT (" Printing Reply ... " );
50- AbstractStreamHttpReply::sendHeader (size);
57+ AbstractStreamHttpReply::sendHeader (size, title );
5158 getStream ().write (buf, size);
5259 DEBUG_ARDUINO_HTTP_SERVER_PRINTLN (" done." );
5360}
0 commit comments