I answer my own question ;-). Here after the correct modification to make in evhttp_handle_request.
in http.c->evhttp_handle_request " if (p == NULL) - res = strcmp(cb->what, req->uri) == 0; + res = strncmp(cb->what, req->uri, strlen(cb->what)) == 0; else res = strncmp(cb->what, req->uri, - (size_t)(p - req->uri)) == 0; + strlen(cb->what)) == 0; if (res) { (*cb->cb)(req, cb->cbarg); " I've included it within my python bridge to libevent and it works great. (I'm progressing with C). I'm already able to use python function as http_event callbacks. Next steps is to make them WSGI compliant ;-). William > > By looking into the libevent code, I think that what must be changed is > the following (evhttp_handle_request in http.c): > > /* Test for different URLs */ > TAILQ_FOREACH(cb, &http->callbacks, next) { > int res; > char *p = strchr(req->uri, '?'); > if (p == NULL) > res = strcmp(cb->what, req->uri) == 0; > else > res = strncmp(cb->what, req->uri, > - (size_t)(p - req->uri)) == 0; > + len(cb->what) == 0; > if (res) { > (*cb->cb)(req, cb->cbarg); > return; > } > } > > > > That way by doing this: > evhttp_set_cb(http_server, "/static/", static_handler, NULL); > the following uri will call static_handler: > - /static/img/home.jpeg > - /static/css/main.css > > > > If I'm not wrong, how can I implement such modification(I'm not a C > expert) ? > Is there a way in C (like we have in python or java) a way to rewrite a > methode of a share library ? > > > Thanks for your help. > > William > > > > > > > >> I would like to know the best way to write a generic handler to dispatch >> my static files located at /static ? >> >> Indeed, evhttp_set_cb needs to have the complete uri. For example, >> /static/img/home.jpg. >> On the orther hand evhttp_set_gencb is generic for the all uri. This is >> a >> of nice way to display "this page is not accessible". >> >> I'm looking an handler that will manage all my static files. In other >> words, when the requestor detect an uri starting by "/static", he should >> always call the same handler. >> >> >> Is there someone who already have think about this ? >> How have you solve it decently ? >> >> Thanks >> >> _______________________________________________ >> Libevent-users mailing list >> Libevent-users@monkey.org >> http://monkey.org/mailman/listinfo/libevent-users >> >> > > > > _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users