Skip to content

Commit cd40f21

Browse files
committed
avoid declaration complexity
1 parent efae5bf commit cd40f21

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -457,21 +457,6 @@ void ESP8266WebServerTemplate<ServerType>::_prepareHeader(String& response, int
457457
_responseHeaders = "";
458458
}
459459

460-
template <typename ServerType>
461-
void ESP8266WebServerTemplate<ServerType>::send(int code, char* content_type, const String& content) {
462-
return send(code, (const char*)content_type, content);
463-
}
464-
465-
template <typename ServerType>
466-
void ESP8266WebServerTemplate<ServerType>::send(int code, const char* content_type, const String& content) {
467-
return send(code, content_type, content.c_str(), content.length());
468-
}
469-
470-
template <typename ServerType>
471-
void ESP8266WebServerTemplate<ServerType>::send(int code, const String& content_type, const String& content) {
472-
return send(code, (const char*)content_type.c_str(), content);
473-
}
474-
475460
template <typename ServerType>
476461
void ESP8266WebServerTemplate<ServerType>::sendContent(const String& content) {
477462
StreamConstPtr ref(content.c_str(), content.length());
@@ -491,18 +476,6 @@ void ESP8266WebServerTemplate<ServerType>::send(int code, const char* content_ty
491476
return sendContent(stream, content_length);
492477
}
493478

494-
template <typename ServerType>
495-
void ESP8266WebServerTemplate<ServerType>::send_P(int code, PGM_P content_type, PGM_P content) {
496-
StreamConstPtr ref(content, strlen_P(content));
497-
return send(code, String(content_type).c_str(), &ref);
498-
}
499-
500-
template <typename ServerType>
501-
void ESP8266WebServerTemplate<ServerType>::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) {
502-
StreamConstPtr ref(content, contentLength);
503-
return send(code, String(content_type).c_str(), &ref);
504-
}
505-
506479
template <typename ServerType>
507480
void ESP8266WebServerTemplate<ServerType>::sendContent(Stream* content, ssize_t content_length /* = 0*/) {
508481
if (_currentMethod == HTTP_HEAD)

libraries/ESP8266WebServer/src/ESP8266WebServer.h

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,37 @@ class ESP8266WebServerTemplate
155155
// code - HTTP response code, can be 200 or 404
156156
// content_type - HTTP content type, like "text/plain" or "image/png"
157157
// 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) {
162168
send_P(code, content_type, content);
163169
}
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) {
165171
send_P(code, content_type, content, content_length);
166172
}
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);
169175
}
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);
174176
void send(int code, const char* content_type, Stream& stream, size_t content_length = 0) {
175177
send(code, content_type, &stream, content_length);
176178
}
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);
177189

178190
void setContentLength(const size_t contentLength);
179191
void sendHeader(const String& name, const String& value, bool first = false);

0 commit comments

Comments
 (0)