Hi all,
I'm looking for a possibility to have only one callback to manage all
those urls:
/static/img/home.jpg
/static/img/banner.jpg
/static/css/style.css
With this sample, I would like to have one callback registered with
"/static/" to manage all of those urls.
Does anyone have an idea ?
Thanks
William
ps:
I've successfully changed evhttp_handle_request wth the following code:
"
void
evhttp_handle_request(struct evhttp_request *req, void *arg)
{
struct evhttp *http = arg;
struct evhttp_cb *cb;
if (req->uri == NULL) {
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
/* Test for different URLs */
TAILQ_FOREACH(cb, &http->callbacks, next) {
int res;
char *p = strchr(req->uri, '?');
if (p == NULL)
res = strncmp(cb->what, req->uri, strlen(cb->what)) == 0;
else
res = strncmp(cb->what, req->uri,
strlen(cb->what)) == 0;
if (res) {
(*cb->cb)(req, cb->cbarg);
return;
}
}
/* Generic call back */
if (http->gencb) {
(*http->gencb)(req, http->gencbarg);
return;
} else {
/* We need to send a 404 here */
char *fmt = "<html><head>"
"<title>404 Not Found</title>"
"</head><body>"
"<h1>Not Found</h1>"
"<p>The requested URL %s was not found on this server.</p>"
"</body></html>\n";
send_error(req, fmt);
}
}
"
_______________________________________________
Libevent-users mailing list
[email protected]
http://monkeymail.org/mailman/listinfo/libevent-users