// but we'll start sending immediately as we get data.
// This is postcondition #3.
client->state = Client::SENDING_DATA;
- client->stream_pos = client->stream->bytes_received;
+ if (client->stream_pos == size_t(-2)) {
+ client->stream_pos = std::min<size_t>(
+ client->stream->bytes_received - client->stream->backlog_size,
+ 0);
+ } else {
+ // client->stream_pos should be -1, but it might not be,
+ // if we have clients from an older version.
+ client->stream_pos = client->stream->bytes_received;
+ }
client->stream->put_client_to_sleep(client);
return;
}
return 400; // Should maybe be 405 instead?
}
- map<string, int>::const_iterator url_map_it = url_map.find(request_tokens[1]);
+ string url = request_tokens[1];
+ if (url.find("?backlog") == url.size() - 8) {
+ client->stream_pos = -2;
+ url = url.substr(0, url.size() - 8);
+ } else {
+ client->stream_pos = -1;
+ }
+
+ map<string, int>::const_iterator url_map_it = url_map.find(url);
if (url_map_it == url_map.end()) {
return 404; // Not found.
}