void dispatch_HEAD(const char* request, int req_len, int sockfd, struct initvals* inits, struct send_data* snd_record) { if (req_len > 0) { char req_path[512]; sscanf(request, "HEAD %412s HTTP/1.1\n", req_path); int len = strlen(req_path); replace_percents(req_path, len); omit_query(req_path); if (!strstr(req_path, "..")) { char path[256]; strcpy(path, inits->root_dir); strcat(path, req_path); write_file_info(path, sockfd, snd_record); } } else { write_400(sockfd, snd_record); } }
/* * This is called to handle a brand new connection, in it's own thread. * Nothing is know about the type of the connection. * Assert Class: 3 */ void *handle_connection(void *arg) { connection_t *con = (connection_t *)arg; char line[BUFSIZE] = ""; int res; thread_init(); if (!con) { write_log(LOG_DEFAULT, "handle_connection: got NULL connection"); thread_exit(0); } if (info.reverse_lookups) con->hostname = reverse(con->host); sock_set_blocking(con->sock, SOCK_BLOCK); /* Fill line[] with the user header, ends with \n\n */ if ((res = sock_read_lines(con->sock, line, BUFSIZE)) <= 0) { write_log(LOG_DEFAULT, "Socket error on connection %d", con->id); kick_not_connected(con, "Socket error"); thread_exit(0); } if (ice_strncmp(line, "GET", 3) == 0) { client_login(con, line); } else if (ice_strncmp(line, "SOURCE", 6) == 0) { source_login (con, line); } else { write_400 (con); kick_not_connected(con, "Invalid header"); } thread_exit(0); return NULL; }
void dispatch_POST(const char* request, int req_len, int sockfd, struct initvals* inits, struct send_data* snd_record) { write_400(sockfd, snd_record); }