From 3aeaf1d7bef57fdffeee38e8d0ab32a9d48c0ba4 Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Fri, 4 Aug 2023 18:57:49 -0400 Subject: [PATCH] Handle data element for HTTP_UNKNOWN Closes #164 --- http.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index c79c889..288d460 100644 --- a/http.c +++ b/http.c @@ -1195,10 +1195,15 @@ Datum http_request(PG_FUNCTION_ARGS) CURL_SETOPT(g_http_handle, CURLOPT_POSTFIELDS, text_to_cstring(content_text)); } - else if ( method == HTTP_PUT || method == HTTP_PATCH ) + else if ( method == HTTP_PUT || method == HTTP_PATCH || method == HTTP_UNKNOWN ) { if ( method == HTTP_PATCH ) CURL_SETOPT(g_http_handle, CURLOPT_CUSTOMREQUEST, "PATCH"); + + /* Assume the user knows what they are doing and pass unchanged */ + if ( method == HTTP_UNKNOWN ) + CURL_SETOPT(g_http_handle, CURLOPT_CUSTOMREQUEST, method_str); + initStringInfo(&si_read); appendBinaryStringInfo(&si_read, VARDATA(content_text), content_size); CURL_SETOPT(g_http_handle, CURLOPT_UPLOAD, 1); @@ -1206,11 +1211,6 @@ Datum http_request(PG_FUNCTION_ARGS) CURL_SETOPT(g_http_handle, CURLOPT_READDATA, &si_read); CURL_SETOPT(g_http_handle, CURLOPT_INFILESIZE, content_size); } - else if (method == HTTP_UNKNOWN) - { - /* Assume the user knows what they are doing and pass unchanged */ - CURL_SETOPT(g_http_handle, CURLOPT_CUSTOMREQUEST, method_str); - } else { /* Never get here */