@@ -149,18 +149,36 @@ class ESP8266WebServerTemplate
149
149
void sendContent (const char *content) { sendContent_P (content); }
150
150
void sendContent (const char *content, size_t size) { sendContent_P (content, size); }
151
151
152
+ bool chunkedResponseModeStart_P (int code, PGM_P content_type) {
153
+ if (_currentVersion == 0 )
154
+ // no chunk mode in HTTP/1.0
155
+ return false ;
156
+ setContentLength (CONTENT_LENGTH_UNKNOWN);
157
+ send_P (code, content_type, " " );
158
+ return true ;
159
+ }
160
+ bool chunkedResponseModeStart (int code, const char * content_type) {
161
+ return chunkedResponseModeStart_P (code, content_type);
162
+ }
163
+ bool chunkedResponseModeStart (int code, const String& content_type) {
164
+ return chunkedResponseModeStart_P (code, content_type.c_str ());
165
+ }
166
+ void chunkedResponseFinalize () {
167
+ sendContent (emptyString);
168
+ }
169
+
152
170
static String credentialHash (const String& username, const String& realm, const String& password);
153
171
154
172
static String urlDecode (const String& text);
155
173
156
- // Handle a GET request by sending a response header and stream file content to response body
174
+ // Handle a GET request by sending a response header and stream file content to response body
157
175
template <typename T>
158
176
size_t streamFile (T &file, const String& contentType) {
159
177
return streamFile (file, contentType, HTTP_GET);
160
178
}
161
179
162
180
// Implement GET and HEAD requests for files.
163
- // Stream body on HTTP_GET but not on HTTP_HEAD requests.
181
+ // Stream body on HTTP_GET but not on HTTP_HEAD requests.
164
182
template <typename T>
165
183
size_t streamFile (T &file, const String& contentType, HTTPMethod requestMethod) {
166
184
size_t contentLength = 0 ;
0 commit comments