From c9ca0489ed84fb03b9a38569e72941687d8fa381 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Fri, 23 Jul 2021 22:04:42 -0600 Subject: [PATCH] allow concurrent POST requests to same URL --- tasks/task_http.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tasks/task_http.c b/tasks/task_http.c index eac88020ed..164ec350d9 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -280,25 +280,34 @@ static void* task_push_http_transfer_generic( const char *url, bool mute, const char *type, retro_task_callback_t cb, void *user_data) { - task_finder_data_t find_data; retro_task_t *t = NULL; http_handle_t *http = NULL; - find_data.func = task_http_finder; - find_data.userdata = (void*)url; - - /* Concurrent download of the same file is not allowed */ - if (task_queue_find(&find_data)) - { - if (conn) - net_http_connection_free(conn); - - return NULL; - } - if (!conn) return NULL; + if (conn->methodcopy && (conn->methodcopy[0] == 'P' || conn->methodcopy[0] == 'p')) + { + /* POST requests usually mutate the server, so assume multiple calls are + * intended, even if they're duplicated. Additionally, they may differ + * only by the POST data, and task_http_finder doesn't look at that, so + * unique requests could be misclassified as duplicates. + */ + } + else + { + task_finder_data_t find_data; + find_data.func = task_http_finder; + find_data.userdata = (void*)url; + + /* Concurrent download of the same file is not allowed */ + if (task_queue_find(&find_data)) + { + net_http_connection_free(conn); + return NULL; + } + } + http = (http_handle_t*)malloc(sizeof(*http)); if (!http)