]> git.sesse.net Git - cubemap/blobdiff - server.cpp
Release Cubemap 1.2.2.
[cubemap] / server.cpp
index 9d15e08771d582f65f43e43a9a18ac7dfcd62e7e..9b83ddccd4fd0ff53f39bd08a702495312282d5b 100644 (file)
@@ -359,7 +359,7 @@ void Server::set_pacing_rate(int stream_index, uint32_t pacing_rate)
        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());
@@ -425,8 +425,8 @@ read_request_again:
                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);
                }
@@ -659,7 +659,7 @@ int Server::parse_request(Client *client)
                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.
                }
        }
 
@@ -737,27 +737,23 @@ void Server::construct_error(Client *client, int error_code)
        }
 }
 
-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.