+// Caller has requested /ctdl/p or /ctdl/p/ but we still have to dispatch based on the method
+void ctdl_p_base(struct http_transaction *h, struct ctdlsession *c) {
+ upload_files(h, c); // we should only do this for POST requests
+}
+
+
+// Handle operations on a specific upload
+void specific_upload(struct http_transaction *h, struct ctdlsession *c, char *name) {
+ int i;
+ struct uploaded_file *u;
+ struct uploaded_file this_one;
+
+ if (upload_list == NULL) {
+ do_404(h);
+ return;
+ }
+
+ memset(&this_one, 0, sizeof(struct uploaded_file));
+ pthread_mutex_lock(&upload_list_mutex);
+ for (i=0; i<array_len(upload_list); ++i) {
+ u = (struct uploaded_file *) array_get_element_at(upload_list, i), sizeof(struct uploaded_file);
+ if (!strcmp(u->id, name)) {
+ memcpy(&this_one, u, sizeof(struct uploaded_file));
+ i = array_len(upload_list) + 1; // Go out of scope; we're done here
+ }
+ }
+ pthread_mutex_unlock(&upload_list_mutex);
+
+ // If we found a matching ID, now dispatch based on the HTTP method.
+
+ if (IsEmptyStr(this_one.id)) { // didn't find a match
+ do_404(h);
+ }
+ else if (!strcasecmp(h->method, "GET")) { // fetch the item
+ do_405(h);
+ }
+ else if (!strcasecmp(h->method, "DELETE")) { // delete the item
+ do_405(h);
+ }
+ else { // unsupported method
+ do_405(h);
+ }
+}
+
+