Lines Matching defs:http

101 #include "event2/http.h"
111 #include "http-internal.h"
207 static int evhttp_find_vhost(struct evhttp *http, struct evhttp **outhttp,
602 /** Generate all headers appropriate for sending the http request in req (or
751 * or an http layer error. for problems on the network
805 * http connection's bufferevent */
1242 struct evhttp *http = evcon->http_server;
1243 TAILQ_REMOVE(&http->connections, evcon, next);
1340 least likely to disrupt the rest of the bufferevent and http code.
1884 /* If we have an absolute-URI, check to see if it is an http request
1889 if (scheme && (!evutil_ascii_strcasecmp(scheme, "http") ||
3393 Search the vhost hierarchy beginning with http for a server alias
3395 outhttp is set to the matching http object and 1 is returned.
3399 evhttp_find_alias(struct evhttp *http, struct evhttp **outhttp,
3405 TAILQ_FOREACH(alias, &http->aliases, next) {
3409 *outhttp = http;
3416 TAILQ_FOREACH(vhost, &http->virtualhosts, next_vhost) {
3425 Attempts to find the best http object to handle a request for a hostname.
3426 All aliases for the root http object and vhosts are searched for an exact
3431 is set with the best matching http object. If there are no matches, the
3432 root http object is stored in outhttp and 0 is returned.
3436 evhttp_find_vhost(struct evhttp *http, struct evhttp **outhttp,
3443 if (evhttp_find_alias(http, outhttp, hostname))
3447 oldhttp = http;
3448 TAILQ_FOREACH(vhost, &http->virtualhosts, next_vhost) {
3451 http = vhost;
3456 } while (oldhttp != http);
3459 *outhttp = http;
3467 struct evhttp *http = arg;
3481 if ((http->allowed_methods & req->type) == 0) {
3483 (unsigned)req->type, (unsigned)http->allowed_methods));
3491 evhttp_find_vhost(http, &http, hostname);
3494 if ((cb = evhttp_dispatch_callback(&http->callbacks, req)) != NULL) {
3500 if (http->gencb) {
3501 (*http->gencb)(req, http->gencbarg);
3543 struct evhttp *http = arg;
3545 evhttp_get_request(http, nfd, peer_sa, peer_socklen);
3549 evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port)
3552 evhttp_bind_socket_with_handle(http, address, port);
3559 evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port)
3576 bound = evhttp_accept_socket_with_handle(http, fd);
3588 evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd)
3591 evhttp_accept_socket_with_handle(http, fd);
3598 evhttp_foreach_bound_socket(struct evhttp *http,
3604 TAILQ_FOREACH(bound, &http->sockets, next)
3609 evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd)
3616 listener = evconnlistener_new(http->base, NULL, NULL,
3623 bound = evhttp_bind_listener(http, listener);
3632 evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener)
3641 TAILQ_INSERT_TAIL(&http->sockets, bound, next);
3643 evconnlistener_set_cb(listener, accept_socket_cb, http);
3660 evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound)
3662 TAILQ_REMOVE(&http->sockets, bound, next);
3670 struct evhttp *http = NULL;
3672 if ((http = mm_calloc(1, sizeof(struct evhttp))) == NULL) {
3677 evutil_timerclear(&http->timeout);
3678 evhttp_set_max_headers_size(http, EV_SIZE_MAX);
3679 evhttp_set_max_body_size(http, EV_SIZE_MAX);
3680 evhttp_set_default_content_type(http, "text/html; charset=ISO-8859-1");
3681 evhttp_set_allowed_methods(http,
3688 TAILQ_INIT(&http->sockets);
3689 TAILQ_INIT(&http->callbacks);
3690 TAILQ_INIT(&http->connections);
3691 TAILQ_INIT(&http->virtualhosts);
3692 TAILQ_INIT(&http->aliases);
3694 return (http);
3700 struct evhttp *http = NULL;
3702 http = evhttp_new_object();
3703 if (http == NULL)
3705 http->base = base;
3707 return (http);
3717 struct evhttp *http = NULL;
3719 http = evhttp_new_object();
3720 if (http == NULL)
3722 if (evhttp_bind_socket(http, address, port) == -1) {
3723 mm_free(http);
3727 return (http);
3731 evhttp_free(struct evhttp* http)
3740 while ((bound = TAILQ_FIRST(&http->sockets)) != NULL) {
3741 TAILQ_REMOVE(&http->sockets, bound, next);
3748 while ((evcon = TAILQ_FIRST(&http->connections)) != NULL) {
3753 while ((http_cb = TAILQ_FIRST(&http->callbacks)) != NULL) {
3754 TAILQ_REMOVE(&http->callbacks, http_cb, next);
3759 while ((vhost = TAILQ_FIRST(&http->virtualhosts)) != NULL) {
3760 TAILQ_REMOVE(&http->virtualhosts, vhost, next_vhost);
3765 if (http->vhost_pattern != NULL)
3766 mm_free(http->vhost_pattern);
3768 while ((alias = TAILQ_FIRST(&http->aliases)) != NULL) {
3769 TAILQ_REMOVE(&http->aliases, alias, next);
3774 mm_free(http);
3778 evhttp_add_virtual_host(struct evhttp* http, const char *pattern,
3790 TAILQ_INSERT_TAIL(&http->virtualhosts, vhost, next_vhost);
3796 evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost)
3801 TAILQ_REMOVE(&http->virtualhosts, vhost, next_vhost);
3810 evhttp_add_server_alias(struct evhttp *http, const char *alias)
3824 TAILQ_INSERT_TAIL(&http->aliases, evalias, next);
3830 evhttp_remove_server_alias(struct evhttp *http, const char *alias)
3834 TAILQ_FOREACH(evalias, &http->aliases, next) {
3836 TAILQ_REMOVE(&http->aliases, evalias, next);
3847 evhttp_set_timeout(struct evhttp* http, int timeout_in_secs)
3850 evhttp_set_timeout_tv(http, NULL);
3855 evhttp_set_timeout_tv(http, &tv);
3860 evhttp_set_timeout_tv(struct evhttp* http, const struct timeval* tv)
3863 http->timeout = *tv;
3865 evutil_timerclear(&http->timeout);
3869 int evhttp_set_flags(struct evhttp *http, int flags)
3876 http->flags &= ~avail_flags;
3878 http->flags |= flags;
3884 evhttp_set_max_headers_size(struct evhttp* http, ev_ssize_t max_headers_size)
3887 http->default_max_headers_size = EV_SIZE_MAX;
3889 http->default_max_headers_size = max_headers_size;
3893 evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size)
3896 http->default_max_body_size = EV_UINT64_MAX;
3898 http->default_max_body_size = max_body_size;
3902 evhttp_set_default_content_type(struct evhttp *http,
3904 http->default_content_type = content_type;
3908 evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods)
3910 http->allowed_methods = methods;
3914 evhttp_set_cb(struct evhttp *http, const char *uri,
3919 TAILQ_FOREACH(http_cb, &http->callbacks, next) {
3938 TAILQ_INSERT_TAIL(&http->callbacks, http_cb, next);
3944 evhttp_del_cb(struct evhttp *http, const char *uri)
3948 TAILQ_FOREACH(http_cb, &http->callbacks, next) {
3955 TAILQ_REMOVE(&http->callbacks, http_cb, next);
3963 evhttp_set_gencb(struct evhttp *http,
3966 http->gencb = cb;
3967 http->gencbarg = cbarg;
3971 evhttp_set_bevcb(struct evhttp *http,
3974 http->bevcb = cb;
3975 http->bevcbarg = cbarg;
4225 struct evhttp* http,
4249 /* we need a connection object to put the http request on */
4250 if (http->bevcb != NULL) {
4251 bev = (*http->bevcb)(http->base, http->bevcbarg);
4254 http->base, NULL, bev, hostname, atoi(portname));
4260 evcon->max_headers_size = http->default_max_headers_size;
4261 evcon->max_body_size = http->default_max_body_size;
4262 if (http->flags & EVHTTP_SERVER_LINGERING_CLOSE)
4288 struct evhttp *http = evcon->http_server;
4290 if ((req = evhttp_request_new(evhttp_handle_request, http)) == NULL)
4321 evhttp_get_request(struct evhttp *http, evutil_socket_t fd,
4326 evcon = evhttp_get_request_connection(http, fd, sa, salen);
4335 if (evutil_timerisset(&http->timeout))
4336 evhttp_connection_set_timeout_tv(evcon, &http->timeout);
4340 * we need to know which http server it belongs to.
4342 evcon->http_server = http;
4343 TAILQ_INSERT_TAIL(&http->connections, evcon, next);
4482 char *scheme; /* scheme; e.g http, ftp etc */