if (_config->FindB("aptwebserver::support::last-modified", true) == true)
{
std::string lastmodified("Last-Modified: ");
- lastmodified.append(TimeRFC1123(data.ModificationTime()));
+ lastmodified.append(TimeRFC1123(data.ModificationTime(), false));
headers.push_back(lastmodified);
}
}
_config->Set("APTWebserver::Last-Status-Code", httpcode);
std::stringstream buffer;
+ auto const empties = _config->FindVector("aptwebserver::empty-response-header");
+ for (auto && e: empties)
+ buffer << e << ":" << std::endl;
_config->Dump(buffer, "aptwebserver::response-header", "%t: %v%n", false);
std::vector<std::string> addheaders = VectorizeString(buffer.str(), '\n');
for (std::vector<std::string>::const_iterator h = addheaders.begin(); h != addheaders.end(); ++h)
headers.push_back(*h);
std::string date("Date: ");
- date.append(TimeRFC1123(time(NULL)));
+ date.append(TimeRFC1123(time(NULL), false));
headers.push_back(date);
if (chunkedTransferEncoding(headers) == true)
<< "<td><a href=\"" << namelist[i]->d_name << "\">" << namelist[i]->d_name << "</a></td>"
<< "<td>" << SizeToStr(fs.st_size) << "B</td>";
}
- listing << "<td>" << TimeRFC1123(fs.st_mtime) << "</td></tr>" << std::endl;
+ listing << "<td>" << TimeRFC1123(fs.st_mtime, true) << "</td></tr>" << std::endl;
}
listing << "</table></body></html>" << std::endl;
condition.clear();
if (condition.empty() == false && strncmp(condition.c_str(), "bytes=", 6) == 0)
{
+ std::string ranges = ',' + _config->Find("aptwebserver::response-header::Accept-Ranges") + ',';
+ ranges.erase(std::remove(ranges.begin(), ranges.end(), ' '), ranges.end());
+ if (ranges.find(",bytes,") == std::string::npos)
+ {
+ // we handle it as an error here because we are a test server - a real one should just ignore it
+ sendError(client, 400, *m, sendContent, "Client does range requests we don't support", headers);
+ continue;
+ }
+
time_t cache;
std::string ifrange;
if (_config->FindB("aptwebserver::support::if-range", true) == true)
headers.push_back(contentrange.str());
}
sendError(client, 416, *m, sendContent, "", headers);
- break;
+ continue;
}
}
}