streams[stream_index]->pacing_rate = pacing_rate;
}
-void Server::add_ping(const std::string &url, const std::string &allow_origin)
+void Server::add_gen204(const std::string &url, const std::string &allow_origin)
{
MutexLock lock(&mutex);
assert(clients.empty());
int error_code = parse_request(client);
if (error_code == 200) {
construct_header(client);
- } else if (error_code == -200) {
- construct_pong(client);
+ } else if (error_code == 204) {
+ construct_204(client);
} else {
construct_error(client, error_code);
}
if (ping_url_map_it == ping_url_map.end()) {
return 404; // Not found.
} else {
- return -200; // Special internal error code for pong.
+ return 204; // No error.
}
}
}
}
-void Server::construct_pong(Client *client)
+void Server::construct_204(Client *client)
{
map<string, string>::const_iterator ping_url_map_it = ping_url_map.find(client->url);
assert(ping_url_map_it != ping_url_map.end());
if (ping_url_map_it->second.empty()) {
client->header_or_short_response =
- "HTTP/1.0 200 OK\r\n"
- "Content-type: text/plain\r\n"
- "\r\n"
- "Pong!\r\n";
+ "HTTP/1.0 204 No Content\r\n"
+ "\r\n";
} else {
- char pong[256];
- snprintf(pong, 256,
- "HTTP/1.0 200 OK\r\n"
- "Content-type: text/plain\r\n"
+ char response[256];
+ snprintf(response, 256,
+ "HTTP/1.0 204 No Content\r\n"
"Access-Control-Allow-Origin: %s\r\n"
- "\r\n"
- "Pong!\r\n",
+ "\r\n",
ping_url_map_it->second.c_str());
- client->header_or_short_response = pong;
+ client->header_or_short_response = response;
}
// Switch states.