@@ -155,25 +155,37 @@ class ESP8266WebServerTemplate
155
155
// code - HTTP response code, can be 200 or 404
156
156
// content_type - HTTP content type, like "text/plain" or "image/png"
157
157
// content - actual content body
158
- void send (int code, const char * content_type = NULL , const String& content = emptyString);
159
- void send (int code, char * content_type, const String& content);
160
- void send (int code, const String& content_type, const String& content);
161
- void send (int code, const char *content_type, const char *content) {
158
+ void send (int code, const char * content_type = NULL , const String& content = emptyString) {
159
+ return send (code, content_type, content.c_str (), content.length ());
160
+ }
161
+ void send (int code, char * content_type, const String& content) {
162
+ return send (code, (const char *)content_type, content);
163
+ }
164
+ void send (int code, const String& content_type, const String& content) {
165
+ return send (code, (const char *)content_type.c_str (), content);
166
+ }
167
+ void send (int code, const char * content_type, const char * content) {
162
168
send_P (code, content_type, content);
163
169
}
164
- void send (int code, const char * content_type, const char * content, size_t content_length) {
170
+ void send (int code, const char * content_type, const char * content, size_t content_length) {
165
171
send_P (code, content_type, content, content_length);
166
172
}
167
- void send (int code, const char * content_type, const uint8_t * content, size_t content_length) {
168
- send_P (code, content_type, (const char * )content, content_length);
173
+ void send (int code, const char * content_type, const uint8_t * content, size_t content_length) {
174
+ send_P (code, content_type, (const char * )content, content_length);
169
175
}
170
- void send_P (int code, PGM_P content_type, PGM_P content);
171
- void send_P (int code, PGM_P content_type, PGM_P content, size_t contentLength);
172
-
173
- void send (int code, const char * content_type, Stream* stream, size_t content_length = 0 );
174
176
void send (int code, const char * content_type, Stream& stream, size_t content_length = 0 ) {
175
177
send (code, content_type, &stream, content_length);
176
178
}
179
+ void send_P (int code, PGM_P content_type, PGM_P content) {
180
+ StreamConstPtr ref (content, strlen_P (content));
181
+ return send (code, String (content_type).c_str (), &ref);
182
+ }
183
+ void send_P (int code, PGM_P content_type, PGM_P content, size_t contentLength) {
184
+ StreamConstPtr ref (content, contentLength);
185
+ return send (code, String (content_type).c_str (), &ref);
186
+ }
187
+
188
+ void send (int code, const char * content_type, Stream* stream, size_t content_length = 0 );
177
189
178
190
void setContentLength (const size_t contentLength);
179
191
void sendHeader (const String& name, const String& value, bool first = false );
0 commit comments