27 #ifndef _EVENT2_HTTP_H_ 28 #define _EVENT2_HTTP_H_ 54 #define HTTP_NOCONTENT 204 55 #define HTTP_MOVEPERM 301 56 #define HTTP_MOVETEMP 302 57 #define HTTP_NOTMODIFIED 304 58 #define HTTP_BADREQUEST 400 59 #define HTTP_NOTFOUND 404 60 #define HTTP_BADMETHOD 405 61 #define HTTP_ENTITYTOOLARGE 413 62 #define HTTP_EXPECTATIONFAILED 417 63 #define HTTP_INTERNAL 500 64 #define HTTP_NOTIMPLEMENTED 501 65 #define HTTP_SERVUNAVAIL 503 68 struct evhttp_request;
70 struct evhttp_bound_socket;
71 struct evconnlistener;
144 struct evhttp_bound_socket *
evhttp_bind_listener(
struct evhttp *http,
struct evconnlistener *listener);
217 void (*cb)(
struct evhttp_request *,
void *),
void *cb_arg);
234 void (*cb)(
struct evhttp_request *,
void *),
void *arg);
259 struct evhttp* vhost);
325 const char *reason,
struct evbuffer *databuf);
378 EVHTTP_REQ_GET = 1 << 0,
379 EVHTTP_REQ_POST = 1 << 1,
380 EVHTTP_REQ_HEAD = 1 << 2,
381 EVHTTP_REQ_PUT = 1 << 3,
382 EVHTTP_REQ_DELETE = 1 << 4,
383 EVHTTP_REQ_OPTIONS = 1 << 5,
384 EVHTTP_REQ_TRACE = 1 << 6,
385 EVHTTP_REQ_CONNECT = 1 << 7,
386 EVHTTP_REQ_PATCH = 1 << 8
398 void (*cb)(
struct evhttp_request *,
void *),
void *arg);
408 void (*cb)(
struct evhttp_request *,
void *));
428 struct event_base *base,
struct evdns_base *dnsbase,
429 const char *address,
unsigned short port);
435 struct evhttp_connection *evcon);
460 void evhttp_connection_set_max_headers_size(
struct evhttp_connection *evcon,
461 ev_ssize_t new_max_headers_size);
463 void evhttp_connection_set_max_body_size(
struct evhttp_connection* evcon,
464 ev_ssize_t new_max_body_size);
471 const char *address);
479 int timeout_in_secs);
487 void (*)(
struct evhttp_connection *,
void *),
void *);
491 char **address, ev_uint16_t *port);
507 struct evhttp_request *req,
537 int evhttp_request_get_response_code(
const struct evhttp_request *req);
586 int evhttp_add_header(
struct evkeyvalq *headers,
const char *key,
const char *value);
625 char *
evhttp_uriencode(
const char *str, ev_ssize_t size,
int space_to_plus);
830 #define EVHTTP_URI_NONCONFORMANT 0x01 857 char *
evhttp_uri_join(
struct evhttp_uri *uri,
char *buf,
size_t limit);
int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers)
Helper function to parse out arguments from the query portion of an HTTP URI.
int evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme)
Set the scheme of an evhttp_uri, or clear the scheme if scheme==NULL.
int evhttp_make_request(struct evhttp_connection *evcon, struct evhttp_request *req, enum evhttp_cmd_type type, const char *uri)
Make an HTTP request over the specified connection.
char * evhttp_encode_uri(const char *str)
Helper function to encode a string for inclusion in a URI.
struct evkeyvalq * evhttp_request_get_input_headers(struct evhttp_request *req)
Returns the input headers.
int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment)
Set the fragment of an evhttp_uri, or clear the fragment if fragment==NULL.
void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs)
Set the timeout for an HTTP request.
char * evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus)
As evhttp_encode_uri, but if 'size' is nonnegative, treat the string as being 'size' bytes long...
void evhttp_connection_set_retries(struct evhttp_connection *evcon, int retry_max)
Sets the retry limit for this connection - -1 repeats indefinitely.
int evhttp_remove_virtual_host(struct evhttp *http, struct evhttp *vhost)
Removes a virtual host from the http server.
const char * evhttp_uri_get_path(const struct evhttp_uri *uri)
Return the path part of an evhttp_uri, or NULL if it has no path set.
const char * evhttp_uri_get_scheme(const struct evhttp_uri *uri)
Return the scheme of an evhttp_uri, or NULL if there is no scheme has been set and the evhttp_uri con...
int evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo)
Set the userinfo of an evhttp_uri, or clear the userinfo if userinfo==NULL.
struct evbuffer * evhttp_request_get_input_buffer(struct evhttp_request *req)
Returns the input buffer.
void evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
Send another data chunk as part of an ongoing chunked reply.
struct evhttp * evhttp_new(struct event_base *base)
Create a new HTTP server.
void evhttp_connection_get_peer(struct evhttp_connection *evcon, char **address, ev_uint16_t *port)
Get the remote address and port associated with this connection.
int evhttp_del_cb(struct evhttp *, const char *)
Removes the callback for a specified URI.
int evhttp_parse_query(const char *uri, struct evkeyvalq *headers)
Helper function to parse out arguments in a query.
const struct evhttp_uri * evhttp_request_get_evhttp_uri(const struct evhttp_request *req)
Returns the request URI (parsed)
void evhttp_request_set_chunked_cb(struct evhttp_request *, void(*cb)(struct evhttp_request *, void *))
Enable delivery of chunks to requestor.
struct bufferevent * evhttp_connection_get_bufferevent(struct evhttp_connection *evcon)
Return the bufferevent that an evhttp_connection is using.
struct evkeyvalq * evhttp_request_get_output_headers(struct evhttp_request *req)
Returns the output headers.
void evhttp_send_reply_end(struct evhttp_request *req)
Complete a chunked reply, freeing the request as appropriate.
struct evhttp_request * evhttp_request_new(void(*cb)(struct evhttp_request *, void *), void *arg)
Creates a new request object that needs to be filled in with the request parameters.
int evhttp_remove_header(struct evkeyvalq *headers, const char *key)
Removes a header from a list of existing headers.
int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port)
Binds an HTTP server on the specified address and port.
struct evconnlistener * evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound)
Return the listener used to implement a bound socket.
void evhttp_send_error(struct evhttp_request *req, int error, const char *reason)
Send an HTML error message to the client.
struct evhttp_bound_socket * evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener)
The most low-level evhttp_bind/accept method: takes an evconnlistener, and returns an evhttp_bound_so...
int evhttp_uri_set_query(struct evhttp_uri *uri, const char *query)
Set the query of an evhttp_uri, or clear the query if query==NULL.
evhttp_request_kind
a request object can represent either a request or a reply
Definition: http.h:390
void evhttp_free(struct evhttp *http)
Free the previously created HTTP server.
struct evhttp_uri * evhttp_uri_new(void)
Return a new empty evhttp_uri with no fields set.
void evhttp_connection_set_local_port(struct evhttp_connection *evcon, ev_uint16_t port)
sets the local port from which http connections are made
struct evhttp_uri * evhttp_uri_parse(const char *source_uri)
Alias for evhttp_uri_parse_with_flags(source_uri, 0)
struct event_base * evhttp_connection_get_base(struct evhttp_connection *req)
Returns the underlying event_base for this connection.
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:274
int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd)
Makes an HTTP server accept connections on the specified socket.
void evhttp_set_max_body_size(struct evhttp *http, ev_ssize_t max_body_size)
XXX Document.
struct evhttp_bound_socket * evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd)
Like evhttp_accept_socket(), but returns a handle for referencing the socket.
void evhttp_request_free(struct evhttp_request *req)
Frees the request object and removes associated events.
void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound_socket)
Makes an HTTP server stop accepting connections on the specified socket.
evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket)
Get the raw file descriptor referenced by an evhttp_bound_socket.
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:95
int evhttp_uri_set_path(struct evhttp_uri *uri, const char *path)
Set the path of an evhttp_uri, or clear the path if path==NULL.
void evhttp_set_max_headers_size(struct evhttp *http, ev_ssize_t max_headers_size)
XXX Document.
struct evhttp_uri * evhttp_uri_parse_with_flags(const char *source_uri, unsigned flags)
Helper function to parse a URI-Reference as specified by RFC3986.
void evhttp_request_own(struct evhttp_request *req)
Takes ownership of the request object.
void evhttp_cancel_request(struct evhttp_request *req)
Cancels a pending HTTP request.
const char * evhttp_uri_get_fragment(const struct evhttp_uri *uri)
Return the fragment part of an evhttp_uri (excluding the leading "#"), or NULL if it has no fragment ...
void evhttp_connection_set_timeout(struct evhttp_connection *evcon, int timeout_in_secs)
Sets the timeout for events related to this connection.
void evhttp_clear_headers(struct evkeyvalq *headers)
Removes all headers from the header list.
Common convenience functions for cross-platform portability and related socket manipulations.
enum evhttp_cmd_type evhttp_request_get_command(const struct evhttp_request *req)
Returns the request command.
void evhttp_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf)
Send an HTML reply to the client.
void evhttp_uri_free(struct evhttp_uri *uri)
Free all memory allocated for a parsed uri.
const char * evhttp_uri_get_host(const struct evhttp_uri *uri)
Return the host part of an evhttp_uri, or NULL if it has no host set.
int evhttp_uri_set_port(struct evhttp_uri *uri, int port)
Set the port of an evhttp_uri, or clear the port if port==-1.
char * evhttp_uridecode(const char *uri, int decode_plus, size_t *size_out)
Helper function to decode a URI-escaped string or HTTP parameter.
char * evhttp_decode_uri(const char *uri)
Helper function to sort of decode a URI-encoded string.
void evhttp_send_reply_start(struct evhttp_request *req, int code, const char *reason)
Initiate a reply that uses Transfer-Encoding chunked.
const char * evhttp_request_get_uri(const struct evhttp_request *req)
Returns the request URI.
int evhttp_set_cb(struct evhttp *http, const char *path, void(*cb)(struct evhttp_request *, void *), void *cb_arg)
Set a callback for a specified URI.
void evhttp_set_gencb(struct evhttp *http, void(*cb)(struct evhttp_request *, void *), void *arg)
Set a callback for all requests that are not caught by specific callbacks.
int evhttp_uri_set_host(struct evhttp_uri *uri, const char *host)
Set the host of an evhttp_uri, or clear the host if host==NULL.
int evhttp_uri_get_port(const struct evhttp_uri *uri)
Return the port part of an evhttp_uri, or -1 if there is no port set.
char * evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit)
Join together the uri parts from parsed data to form a URI-Reference.
void evhttp_set_allowed_methods(struct evhttp *http, ev_uint16_t methods)
Sets the what HTTP methods are supported in requests accepted by this server, and passed to user call...
const char * evhttp_uri_get_userinfo(const struct evhttp_uri *uri)
Return the userinfo part of an evhttp_uri, or NULL if it has no userinfo set.
int evhttp_request_is_owned(struct evhttp_request *req)
Returns 1 if the request is owned by the user.
void evhttp_connection_set_closecb(struct evhttp_connection *evcon, void(*)(struct evhttp_connection *, void *), void *)
Set a callback for connection close.
struct evhttp_connection * evhttp_request_get_connection(struct evhttp_request *req)
Returns the connection object associated with the request or NULL.
char * evhttp_htmlescape(const char *html)
Escape HTML character entities in a string.
struct evbuffer * evhttp_request_get_output_buffer(struct evhttp_request *req)
Returns the output buffer.
void evhttp_connection_free(struct evhttp_connection *evcon)
Frees an http connection.
void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags)
Changes the flags set on a given URI.
const char * evhttp_request_get_host(struct evhttp_request *req)
Returns the host associated with the request.
struct evhttp_connection * evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, const char *address, unsigned short port)
A connection object that can be used to for making HTTP requests.
An opaque type for handling buffered IO.
Definition: bufferevent.h:111
void evhttp_connection_set_local_address(struct evhttp_connection *evcon, const char *address)
sets the ip address from which http connections are made
int evhttp_add_virtual_host(struct evhttp *http, const char *pattern, struct evhttp *vhost)
Adds a virtual host to the http server.
struct evhttp_bound_socket * evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port)
Like evhttp_bind_socket(), but returns a handle for referencing the socket.
int evhttp_remove_server_alias(struct evhttp *http, const char *alias)
Remove a server alias from an http object.
const char * evhttp_uri_get_query(const struct evhttp_uri *uri)
Return the query part of an evhttp_uri (excluding the leading "?"), or NULL if it has no query set...
int evhttp_add_server_alias(struct evhttp *http, const char *alias)
Add a server alias to an http object.
int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *value)
Adds a header to a list of existing headers.
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:213
const char * evhttp_find_header(const struct evkeyvalq *headers, const char *key)
Finds the value belonging to a header.
evhttp_cmd_type
The different request types supported by evhttp.
Definition: http.h:377