paivana

HTTP paywall reverse proxy
Log | Files | Refs | Submodules | README | LICENSE

commit 63c5ea79ca40beb4d6418c45dc78927897648ac4
parent c71b1c811a2593c2b84b1f74714ddef283a07630
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 26 Apr 2026 23:15:20 +0200

add -F flag to continue upload even if response is already being received

Diffstat:
Msrc/backend/paivana-httpd.c | 20++++++++++++++------
Msrc/backend/paivana-httpd.h | 9+++++++++
Msrc/backend/paivana-httpd_reverse.c | 9+++++++++
3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/backend/paivana-httpd.c b/src/backend/paivana-httpd.c @@ -52,6 +52,8 @@ struct GNUNET_CURL_Context *PH_ctx; int PH_no_check; +int PH_force_complete_upload; + int PH_respect_forwarded_headers; unsigned long long PH_request_buffer_max = 1024 * 1024; @@ -306,6 +308,18 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ( + 'f', + "respect-forwarded-headers", + gettext_noop ( + "trust X-Forwarded-For for the client address (only safe behind a trusted reverse proxy)"), + &PH_respect_forwarded_headers), + GNUNET_GETOPT_option_flag ( + 'F', + "force-complete-upload", + gettext_noop ( + "force Paivana to finish the upload even if the server has already started to respond"), + &PH_force_complete_upload), + GNUNET_GETOPT_option_flag ( 'n', "no-payment", gettext_noop ( @@ -318,12 +332,6 @@ main (int argc, gettext_noop ( "maximum request body size to buffer before forwarding (default: 1048576)"), &PH_request_buffer_max), - GNUNET_GETOPT_option_flag ( - 'f', - "respect-forwarded-headers", - gettext_noop ( - "trust X-Forwarded-For for the client address (only safe behind a trusted reverse proxy)"), - &PH_respect_forwarded_headers), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; diff --git a/src/backend/paivana-httpd.h b/src/backend/paivana-httpd.h @@ -65,6 +65,15 @@ extern struct GNUNET_CURL_Context *PH_ctx; extern int PH_no_check; /** + * Force Paivana to complete an upload even if the + * server already started sending a response. This MAY + * fix some data integrity issues, but also could be + * unsupported by some servers and be wasteful if the + * server has already rejected the upload. + */ +extern int PH_force_complete_upload; + +/** * If set, derive the client address from the leftmost entry of the * "X-Forwarded-For" request header (falling back to the socket * address only when the header is absent). Only enable this when diff --git a/src/backend/paivana-httpd_reverse.c b/src/backend/paivana-httpd_reverse.c @@ -853,6 +853,11 @@ curl_upload_cb (void *buf, &hr->io_buf[to_copy], hr->io_len - to_copy); hr->io_len -= to_copy; + if ( (hr->curl_paused) && + (! PH_force_complete_upload) ) + { + hr->io_len = 0; + } if (0 == hr->io_len) { hr->state = REQUEST_STATE_PROXY_DOWNLOAD_STARTED; @@ -1637,6 +1642,10 @@ start_curl_request (struct HttpRequest *hr, curl_easy_setopt (hr->curl, CURLOPT_WRITEDATA, hr); + if (PH_force_complete_upload) + curl_easy_setopt (hr->curl, + CURLOPT_KEEP_SENDING_ON_ERROR, + 1); { char *curlurl;