commit b06e318faaf88b0a861df579a622b152bcf2bc15
parent 3cb4d2638ec6afe4d8ac8dd8deb096adf892dbf0
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 9 Nov 2026 16:22:50 +0100
proxy DELETE (and any other method) instead of dropping the connection
test_twister.sh expanded to cover plain DELETE and DELETE with a
request body, --responsecode on a DELETE, and a PATCH.
Diffstat:
2 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/src/test/test_twister.sh b/src/test/test_twister.sh
@@ -245,6 +245,68 @@ echo "POST big load passed".
rm BIGBLOB*
+# DELETE must be proxied like any other method: the request has
+# to reach the Web server and its answer has to come back.
+delete_body=$(curl -s -X DELETE "${TWISTER_URL}delete-test")
+
+if ! test '{"hello":[{"this":"browser!"}],"when":"today"}' = \
+ "$delete_body"; then
+ printf "DELETE was not proxied, got (%s)\n" "$delete_body"
+ kill $web_server_pid
+ kill $twister_service_pid
+ exit 1
+fi
+
+echo "DELETE proxying passed".
+
+# A DELETE carrying a request body must be forwarded as well.
+status_code=$(curl \
+ -s "${TWISTER_URL}delete-with-body" \
+ -o /dev/null \
+ -X DELETE \
+ -H "Content-Type: application/json" \
+ -d@body.json \
+ -w "%{http_code}")
+
+if ! test 200 = $status_code; then
+ echo "DELETE with a body failed (status == ${status_code})."
+ kill $web_server_pid
+ kill $twister_service_pid
+ exit 1
+fi
+
+echo "DELETE with request body passed".
+
+# Response mutations must still apply to a DELETE.
+taler-twister -c ./test_twister.conf --responsecode 204
+status_code=$(curl -s -X DELETE "${TWISTER_URL}delete-test" \
+ -o /dev/null \
+ -w "%{http_code}")
+
+if ! test 204 = $status_code; then
+ echo "DELETE response code was not hacked (status == ${status_code})."
+ kill $web_server_pid
+ kill $twister_service_pid
+ exit 1
+fi
+
+echo "DELETE response-code hacking passed".
+
+# PATCH is proxied through the same generic path.
+patch_body=$(curl -s -X PATCH "${TWISTER_URL}patch-test" \
+ -H "Content-Type: application/json" \
+ -d@body.json)
+
+if ! test '{"hello":[{"this":"browser!"}],"when":"today"}' = \
+ "$patch_body"; then
+ printf "PATCH was not proxied, got (%s)\n" "$patch_body"
+ kill $web_server_pid
+ kill $twister_service_pid
+ exit 1
+fi
+
+echo "PATCH proxying passed".
+
# shutdown twister and webserver
kill $web_server_pid
kill $twister_service_pid
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c
@@ -1773,12 +1773,30 @@ create_response (void *cls,
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unsupported HTTP method `%s'\n",
+ /* Any other method (DELETE, PATCH, ...) is forwarded
+ * verbatim. cURL copies the method string, so @a meth
+ * does not have to outlive this call. If the client did
+ * send a request body, stream it out the way we do for
+ * PUT; without a body we go straight to reading the
+ * response. Either way the response-side mutations
+ * (response code, truncation, JSON edits) still apply. */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Crafting a CURL `%s' request\n",
meth);
- curl_easy_cleanup (hr->curl);
- hr->curl = NULL;
- return MHD_NO;
+ curl_easy_setopt (hr->curl,
+ CURLOPT_CUSTOMREQUEST,
+ meth);
+ if (0 != hr->io_len)
+ {
+ curl_easy_setopt (hr->curl,
+ CURLOPT_UPLOAD,
+ 1L);
+ hr->state = REQUEST_STATE_PROXY_UPLOAD_STARTED;
+ }
+ else
+ {
+ hr->state = REQUEST_STATE_PROXY_DOWNLOAD_STARTED;
+ }
}
if (0 == strcasecmp (ver,