File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -130,12 +130,6 @@ void AsyncWebServerResponse::addHeader(String name, String value){
130
130
}
131
131
132
132
String AsyncWebServerResponse::_assembleHead (uint8_t version){
133
- if (version){
134
- addHeader (F (" Accept-Ranges" ), F (" none" ));
135
- if (_chunked)
136
- addHeader (F (" Transfer-Encoding" ), F (" chunked" ));
137
- }
138
-
139
133
// Precalculate the output header block length
140
134
size_t est_header_size = 10 + 4 + 2 ; // HTTP://1.version code + newlines
141
135
est_header_size += strlen_P ((const char *) _responseCodeToString (_code));
@@ -145,6 +139,12 @@ String AsyncWebServerResponse::_assembleHead(uint8_t version){
145
139
if (_contentType.length ()) {
146
140
est_header_size += 16 + _contentType.length ();
147
141
}
142
+ if (version) {
143
+ est_header_size += 14 + 5 + 4 ;
144
+ if (_chunked) {
145
+ est_header_size += 18 + 8 + 4 ;
146
+ }
147
+ }
148
148
for (const auto & header: _headers) {
149
149
est_header_size += header.name ().length () + header.value ().length () + 4 ;
150
150
};
@@ -174,6 +174,13 @@ String AsyncWebServerResponse::_assembleHead(uint8_t version){
174
174
}
175
175
_headers.free ();
176
176
177
+ if (version) {
178
+ out.concat (F (" Accept-Ranges: none\r\n " ));
179
+ if (_chunked) {
180
+ out.concat (F (" Transfer-Encoding: chunked\r\n " ));
181
+ }
182
+ }
183
+
177
184
out.concat (F (" \r\n " ));
178
185
_headLength = out.length ();
179
186
return out;
You can’t perform that action at this time.
0 commit comments