+ client->header_or_short_response = error;
+
+ // Switch states.
+ client->state = Client::SENDING_SHORT_RESPONSE;
+
+ epoll_event ev;
+ ev.events = EPOLLOUT | EPOLLET | EPOLLRDHUP;
+ ev.data.u64 = reinterpret_cast<uint64_t>(client);
+
+ if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, client->sock, &ev) == -1) {
+ log_perror("epoll_ctl(EPOLL_CTL_MOD)");
+ exit(1);
+ }
+}
+
+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 204 No Content\r\n"
+ "\r\n";
+ } else {
+ char response[256];
+ snprintf(response, 256,
+ "HTTP/1.0 204 No Content\r\n"
+ "Access-Control-Allow-Origin: %s\r\n"
+ "\r\n",
+ ping_url_map_it->second.c_str());
+ client->header_or_short_response = response;
+ }