[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] [PATCH] http: Allow wildcards in request callback paths
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] [PATCH] http: Allow wildcards in request callback paths
- From: Bobby Powers <bobbypowers@xxxxxxxxx>
- Date: Sat, 10 Jul 2010 01:05:53 -0700
- Cc: Bobby Powers <bobbypowers@xxxxxxxxx>
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sat, 10 Jul 2010 04:06:12 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=B0cIOm0v7zUlWJ4E8frOwSwVjya1SMNBYKtYmIaipfY=; b=JFxCdBwzNF6Cs6cbvRL9WJ9nHYmUNYZOS5mJg4dvXLe37dgUQr9VBcCKmiIFOaJtVs rK21XmxhanG1AGTaXTP0oDSj4tJv70WgGxv3DUt5Uu68f0QUJFAMifxvu0qXJmh91tvX 9csA4Ikp1d/c4UMXdM0EZNDFkbgHBuLiIutDM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=r4rivc2Mgwv+GdnTopKRUrSNlDp7V4RxTSwUC/BlSMb37idxxh6JJGZRZBQspv+TlC 0EtH1tQIK+mDldtdjo5jl6PlbLdNsztNa/46h5il2Tifl7cWSPrUidHTumyHfYKU3aX+ Shv9ZAKnd2JYBgbbx0p9+kL6WwA7Q0WB1lj7w=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
this allows you to register callbacks with paths like "/artist*".
based on the patch here:
http://www.mail-archive.com/libevent-users@xxxxxxxxxx/msg00985.html
Signed-off-by: Bobby Powers <bobbypowers@xxxxxxxxx>
---
http.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/http.c b/http.c
index 19d4f91..1f5b402 100644
--- a/http.c
+++ b/http.c
@@ -2467,8 +2467,14 @@ evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req)
TAILQ_FOREACH(cb, callbacks, next) {
int res = 0;
- res = ((strncmp(cb->what, translated, offset) == 0) &&
- (cb->what[offset] == '\0'));
+ char *multi = strchr(cb->what, '*');
+ if (multi != NULL) {
+ int len = strlen(cb->what) - 1;
+ res = strncmp(cb->what, translated, len) == 0;
+ } else {
+ res = ((strncmp(cb->what, translated, offset) == 0) &&
+ (cb->what[offset] == '\0'));
+ }
if (res) {
mm_free(translated);
--
1.7.1.251.g92a7.dirty
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.