static int upload_progress_handle_request(request_rec *r) { /**/up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server, "upload_progress_handle_request()"); DirConfig* dir = (DirConfig*)ap_get_module_config(r->per_dir_config, &upload_progress_module); ServerConfig *config = get_server_config(r->server); if (dir && dir->track_enabled > 0) { if (r->method_number == M_POST) { int param_error; const char* id = get_progress_id(r, ¶m_error); if (id) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Upload id='%s' in trackable location: %s.", id, r->uri); CACHE_LOCK(); clean_old_connections(r); upload_progress_node_t *node = find_node(r, id); if (node == NULL) { node = insert_node(r, id); if (node) up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Added upload with id='%s' to list.", id); } else if (node->done) { fill_new_upload_node_data(node, r); up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Reused existing node with id='%s'.", id); } else { node = NULL; ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server, "Upload Progress: Upload with id='%s' already exists, ignoring.", id); } if (node) { upload_progress_context_t *ctx = (upload_progress_context_t*)apr_pcalloc(r->pool, sizeof(upload_progress_context_t)); ctx->node = node; ctx->r = r; apr_pool_cleanup_register(r->pool, ctx, upload_progress_cleanup, apr_pool_cleanup_null); ap_add_input_filter("UPLOAD_PROGRESS", NULL, r, r->connection); } CACHE_UNLOCK(); } else if (param_error < 0) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Upload with invalid ID in trackable location: %s.", r->uri); /* return HTTP_BAD_REQUEST; return HTTP_NOT_FOUND; */ } else { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Upload without ID in trackable location: %s.", r->uri); } } } return DECLINED; }
int add_upload_to_track(request_rec* r, const char* key) { ServerConfig *config = get_server_config(r); upload_progress_node_t* node; clean_old_connections(r); CACHE_LOCK(); node = find_node(r, key); if(node == NULL) { node = insert_node(r, key); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Upload Progress: Added upload with id=%s to list.", key); upload_progress_context_t *ctx = (upload_progress_context_t*)apr_pcalloc(r->pool, sizeof(upload_progress_context_t)); ctx->node = node; ctx->r = r; CACHE_UNLOCK(); apr_pool_cleanup_register(r->pool, ctx, upload_progress_cleanup, apr_pool_cleanup_null); return OK; } CACHE_UNLOCK(); return OK; }