Re: [RFC] MEDIUM: lua,http,spoe: add PATCH method to lua httpclient

2025-01-09 Thread Miroslav Zagorac
On 09. 01. 2025. 13:22, Chris Hibbert wrote:
> Well my first contribution is off to an embarrassing start, here is the
> proposed patch attached!
> 

Hello Chris,

I would just like to comment on the part of your patch related to
addons/ot/src/util.c:

I think that instead of HTTP_METH_PATCH, the string content "PATCH" (that is,
HTTP_METH_STR_PATCH which is defined as "PATCH") should be used, and not an
enum as you have.

An example of that part of the patch is in the attachment.


Best regards,

-- 
Miroslav Zagoracdiff --git a/addons/ot/include/util.h b/addons/ot/include/util.h
index 776ddd203..f5739b2a8 100644
--- a/addons/ot/include/util.h
+++ b/addons/ot/include/util.h
@@ -23,6 +23,7 @@
 #define HTTP_METH_STR_OPTIONS   "OPTIONS"
 #define HTTP_METH_STR_GET   "GET"
 #define HTTP_METH_STR_HEAD  "HEAD"
+#define HTTP_METH_STR_PATCH "PATCH"
 #define HTTP_METH_STR_POST  "POST"
 #define HTTP_METH_STR_PUT   "PUT"
 #define HTTP_METH_STR_DELETE"DELETE"
diff --git a/addons/ot/src/util.c b/addons/ot/src/util.c
index fd040164d..4689fbf03 100644
--- a/addons/ot/src/util.c
+++ b/addons/ot/src/util.c
@@ -585,6 +585,11 @@ int flt_ot_sample_to_str(const struct sample_data *data, char *value, size_t siz
 
 		(void)memcpy(value, HTTP_METH_STR_HEAD, retval + 1);
 	}
+	else if (data->u.meth.meth == HTTP_METH_PATCH) {
+		retval = FLT_OT_STR_SIZE(HTTP_METH_STR_PATCH);
+
+		(void)memcpy(value, HTTP_METH_STR_PATCH, retval + 1);
+	}
 	else if (data->u.meth.meth == HTTP_METH_POST) {
 		retval = FLT_OT_STR_SIZE(HTTP_METH_STR_POST);
 


Re: [RFC] MEDIUM: lua,http,spoe: add PATCH method to lua httpclient

2025-01-09 Thread Chris Hibbert
Well my first contribution is off to an embarrassing start, here is the
proposed patch attached!

On Thu, 9 Jan 2025 at 12:19, Chris Hibbert  wrote:

> Currently the httpclient supports these methods: get, head, put, post,
> delete
>
> https://www.arpalert.org/src/haproxy-lua-api/2.9/index.html#httpclient-class
>
> I need patch support, and this has also been requested by others here:
> https://github.com/haproxy/haproxy/issues/2489#issuecomment-2003414422
>
> I have made what I believe are the correct code changes, and have tested
> that I can now send PATCH via the httpclient - this is working fine.
>
> There are some changes I needed to make to add PATCH into the list of
> methods, and a few surrounding changes which I'm not sure how are used/to
> test (e.g. open telemetry, spoe code), I'm very happy to remove any
> unnecessary changes which those with more experience say are not required.
>
> TIA.
>


0001-Add-PATCH-method-to-httpclient.patch
Description: Binary data