return false;
}
- multimap<string, string> parameters;
- for (size_t i = 1; i < lines.size(); ++i) {
- size_t split = lines[i].find(":");
- if (split == string::npos) {
- log(WARNING, "[%s] Ignoring malformed HTTP response line '%s'",
- url.c_str(), lines[i].c_str());
- continue;
- }
-
- string key(lines[i].begin(), lines[i].begin() + split);
-
- // Skip any spaces after the colon.
- do {
- ++split;
- } while (split < lines[i].size() && lines[i][split] == ' ');
+ multimap<string, string> parameters = extract_headers(lines, url);
- string value(lines[i].begin() + split, lines[i].end());
-
- // Remove “Content-encoding: metacube”.
- // TODO: Make case-insensitive.
- if (key == "Content-encoding" && value == "metacube") {
- continue;
- }
-
- parameters.insert(make_pair(key, value));
+ // Remove “Content-encoding: metacube”.
+ // TODO: Make case-insensitive.
+ multimap<string, string>::iterator encoding_it =
+ parameters.find("Content-encoding");
+ if (encoding_it != parameters.end() && encoding_it->second == "metacube") {
+ parameters.erase(encoding_it);
}
// Change “Server: foo” to “Server: metacube/0.1 (reflecting: foo)”
RequestParseStatus status = wait_for_double_newline(&response, buf, ret);
if (status == RP_OUT_OF_SPACE) {
- log(WARNING, "[%s] Sever sent overlong HTTP response!", url.c_str());
+ log(WARNING, "[%s] Server sent overlong HTTP response!", url.c_str());
state = CLOSING_SOCKET;
continue;
} else if (status == RP_NOT_FINISHED_YET) {
has_metacube_header = false;
continue;
}
- if (size > 262144) {
+ if (size > 1048576) {
log(WARNING, "[%s] Metacube block of %d bytes (flags=%x); corrupted header?",
url.c_str(), size, flags);
}
if (num_bytes == 0) {
return;
}
- log(WARNING, "[%s] Dropping %lld junk bytes from stream, maybe it is not a Metacube2 stream?",
+ log(WARNING, "[%s] Dropping %lld junk bytes; not a Metacube2 stream, or data was dropped from the middle of the stream",
url.c_str(), (long long)num_bytes);
assert(pending_data.size() >= num_bytes);
pending_data.erase(pending_data.begin(), pending_data.begin() + num_bytes);