int blizzard::http::commit() { char buff[1024]; char now_str[128]; time_t now_time; time(&now_time); memset(now_str, 0, 128); strftime(now_str, 127, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now_time)); const char * resp_status_str = "Unknown"; if (response_status >= http_codes_num || response_status == 0) { response_status = 404; } else { resp_status_str = http_codes[response_status]; } int l = snprintf(buff, 1023, "HTTP/%d.%d %d %s\r\n" "Server: blizzard/" BLZ_VERSION "\r\n" "Date: %s\r\n", protocol_major, protocol_minor, response_status, resp_status_str, now_str); out_title.append_data(buff, l); if (!cache) { const char m[] = "Pragma: no-cache\r\nCache-control: no-cache\r\n"; out_headers.append_data(m, sizeof(m) - 1); } add_response_header("Connection", "close"); if (out_post.get_data_size()) { add_response_header("Accept-Ranges", "bytes"); l = snprintf(buff, 1023, "Content-Length: %d\r\n", (int)out_post.get_total_data_size()); out_headers.append_data(buff, l); } out_headers.append_data("\r\n", 2); out_title.append_data(out_headers.get_data(), out_headers.get_data_size()); return 0; }
map_responder::map_responder(mime::type mt, bbox b, data_selection &x) : osm_responder(mt, x, boost::optional<bbox>(b)) { // create temporary tables of nodes, ways and relations which // are in or used by elements in the bbox int num_nodes = sel.select_nodes_from_bbox(b, MAX_NODES); // TODO: make configurable parameter? if (num_nodes > MAX_NODES) { throw http::bad_request((format("You requested too many nodes (limit is %1%). " "Either request a smaller area, or use planet.osm") % MAX_NODES).str()); } // Short-circuit empty areas if (num_nodes > 0) { sel.select_ways_from_nodes(); sel.select_nodes_from_way_nodes(); sel.select_relations_from_ways(); sel.select_relations_from_nodes(); sel.select_relations_from_relations(); } // map calls typically have a Content-Disposition header saying that // what's coming back is an attachment. add_response_header("Content-Disposition: attachment; filename=\"map.osm\""); }