diff mbox series

[05/23] mongoose: Forward port deprecated mg_http_match_uri()

Message ID 20240612144010.470339-6-Michael.Glembotzki@iris-sensing.com
State Changes Requested
Headers show
Series Update Mongoose Version to 7.14 | expand

Commit Message

Michael Glembotzki June 12, 2024, 2:36 p.m. UTC
From: Michael Glembotzki <m.glembo@gmail.com>

mongoose rev-id: a025577b30be2fe0a90358702b41b7d8e5afe69f

Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---
 mongoose/mongoose_interface.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

James Hilliard June 13, 2024, 7:32 a.m. UTC | #1
On Wed, Jun 12, 2024 at 8:40 AM Michael Glembotzki <m.glembo@gmail.com> wrote:
>
> From: Michael Glembotzki <m.glembo@gmail.com>
>
> mongoose rev-id: a025577b30be2fe0a90358702b41b7d8e5afe69f

I think rather than forward port this function you should just use mg_match
in our call sites directly similar to the mongoose change upstream.

In general I think it's preferable to migrate to the new mongoose API's
when feasible(i.e. if there's a suitable replacement API) rather than
forward port deprecated API's.

>
> Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
> ---
>  mongoose/mongoose_interface.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
> index 3fbe88e2..86459c33 100644
> --- a/mongoose/mongoose_interface.c
> +++ b/mongoose/mongoose_interface.c
> @@ -196,6 +196,10 @@ static void mg_mkmd5resp(struct mg_str method, struct mg_str uri, struct mg_str
>                    colon, one, ha2, sizeof(ha2) - 1, NULL);
>  }
>
> +static bool mg_http_match_uri(const struct mg_http_message *hm, const char *glob) {
> +       return mg_match(hm->uri, mg_str(glob), NULL);
> +}
> +
>  static double mg_time(void)
>  {
>         struct timeval tv;
> --
> 2.35.7
>
> --
> You received this message because you are subscribed to the Google Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/20240612144010.470339-6-Michael.Glembotzki%40iris-sensing.com.
Michael Glembotzki June 14, 2024, 7:28 a.m. UTC | #2
Hi James,

thanks for the Review!

> James Hilliard schrieb am Donnerstag, 13. Juni 2024 um 09:32:32 UTC+2:
> On Wed, Jun 12, 2024 at 8:40 AM Michael Glembotzki <m.gl...@gmail.com> 
wrote: 
> > 
> > From: Michael Glembotzki <m.gl...@gmail.com> 
> > 
> > mongoose rev-id: a025577b30be2fe0a90358702b41b7d8e5afe69f 
> 
> I think rather than forward port this function you should just use 
mg_match 
> in our call sites directly similar to the mongoose change upstream. 

Agree! Will be adjusted in V2.

> In general I think it's preferable to migrate to the new mongoose API's 
> when feasible(i.e. if there's a suitable replacement API) rather than 
> forward port deprecated API's. 

Unfortunately, the Mongoose project is really not that well managed / or
the development is not that well structured. The commit descriptions are
often empty or meaningless. Functions disappear, interface adjustments
occur or data types disappear for no apparent reason. The only way to find
out what the authors might have been thinking is through reverse
engineering. The best example is removing and bringing back mg_strdup.
For example, I'm not sure whether the decision to remove all the functions
was a good one:
mg_http_match_uri, mg_ncasecmp, mg_vcmp, mg_vcasecmp, mg_strcmp, mg_strstr..

Best regards
Michael
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 3fbe88e2..86459c33 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -196,6 +196,10 @@  static void mg_mkmd5resp(struct mg_str method, struct mg_str uri, struct mg_str
 		   colon, one, ha2, sizeof(ha2) - 1, NULL);
 }
 
+static bool mg_http_match_uri(const struct mg_http_message *hm, const char *glob) {
+	return mg_match(hm->uri, mg_str(glob), NULL);
+}
+
 static double mg_time(void)
 {
 	struct timeval tv;