libevent-2.1.12-stable
http.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef EVENT2_HTTP_H_INCLUDED_
28 #define EVENT2_HTTP_H_INCLUDED_
29 
30 /* For int types. */
31 #include <event2/util.h>
32 #include <event2/visibility.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /* In case we haven't included the right headers yet. */
39 struct evbuffer;
40 struct event_base;
41 struct bufferevent;
42 struct evhttp_connection;
43 
55 /* Response codes */
56 #define HTTP_OK 200
57 #define HTTP_NOCONTENT 204
58 #define HTTP_MOVEPERM 301
59 #define HTTP_MOVETEMP 302
60 #define HTTP_NOTMODIFIED 304
61 #define HTTP_BADREQUEST 400
62 #define HTTP_NOTFOUND 404
63 #define HTTP_BADMETHOD 405
64 #define HTTP_ENTITYTOOLARGE 413
65 #define HTTP_EXPECTATIONFAILED 417
66 #define HTTP_INTERNAL 500
67 #define HTTP_NOTIMPLEMENTED 501
68 #define HTTP_SERVUNAVAIL 503
70 struct evhttp;
71 struct evhttp_request;
72 struct evkeyvalq;
73 struct evhttp_bound_socket;
74 struct evconnlistener;
75 struct evdns_base;
76 
85 EVENT2_EXPORT_SYMBOL
86 struct evhttp *evhttp_new(struct event_base *base);
87 
100 EVENT2_EXPORT_SYMBOL
101 int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port);
102 
114 EVENT2_EXPORT_SYMBOL
115 struct evhttp_bound_socket *evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port);
116 
133 EVENT2_EXPORT_SYMBOL
134 int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd);
135 
146 EVENT2_EXPORT_SYMBOL
147 struct evhttp_bound_socket *evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd);
148 
154 EVENT2_EXPORT_SYMBOL
155 struct evhttp_bound_socket *evhttp_bind_listener(struct evhttp *http, struct evconnlistener *listener);
156 
160 EVENT2_EXPORT_SYMBOL
161 struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound);
162 
163 typedef void evhttp_bound_socket_foreach_fn(struct evhttp_bound_socket *, void *);
174 EVENT2_EXPORT_SYMBOL
175 void evhttp_foreach_bound_socket(struct evhttp *http, evhttp_bound_socket_foreach_fn *function, void *argument);
176 
194 EVENT2_EXPORT_SYMBOL
195 void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound_socket);
196 
204 EVENT2_EXPORT_SYMBOL
205 evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket);
206 
215 EVENT2_EXPORT_SYMBOL
216 void evhttp_free(struct evhttp* http);
217 
219 EVENT2_EXPORT_SYMBOL
220 void evhttp_set_max_headers_size(struct evhttp* http, ev_ssize_t max_headers_size);
222 EVENT2_EXPORT_SYMBOL
223 void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size);
224 
233 EVENT2_EXPORT_SYMBOL
234 void evhttp_set_default_content_type(struct evhttp *http,
235  const char *content_type);
236 
248 EVENT2_EXPORT_SYMBOL
249 void evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods);
250 
260 EVENT2_EXPORT_SYMBOL
261 int evhttp_set_cb(struct evhttp *http, const char *path,
262  void (*cb)(struct evhttp_request *, void *), void *cb_arg);
263 
265 EVENT2_EXPORT_SYMBOL
266 int evhttp_del_cb(struct evhttp *, const char *);
267 
279 EVENT2_EXPORT_SYMBOL
280 void evhttp_set_gencb(struct evhttp *http,
281  void (*cb)(struct evhttp_request *, void *), void *arg);
282 
297 EVENT2_EXPORT_SYMBOL
298 void evhttp_set_bevcb(struct evhttp *http,
299  struct bufferevent *(*cb)(struct event_base *, void *), void *arg);
300 
323 EVENT2_EXPORT_SYMBOL
324 int evhttp_add_virtual_host(struct evhttp* http, const char *pattern,
325  struct evhttp* vhost);
326 
335 EVENT2_EXPORT_SYMBOL
336 int evhttp_remove_virtual_host(struct evhttp* http, struct evhttp* vhost);
337 
346 EVENT2_EXPORT_SYMBOL
347 int evhttp_add_server_alias(struct evhttp *http, const char *alias);
348 
356 EVENT2_EXPORT_SYMBOL
357 int evhttp_remove_server_alias(struct evhttp *http, const char *alias);
358 
365 EVENT2_EXPORT_SYMBOL
366 void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs);
367 
374 EVENT2_EXPORT_SYMBOL
375 void evhttp_set_timeout_tv(struct evhttp *http, const struct timeval* tv);
376 
377 /* Read all the clients body, and only after this respond with an error if the
378  * clients body exceed max_body_size */
379 #define EVHTTP_SERVER_LINGERING_CLOSE 0x0001
380 
387 EVENT2_EXPORT_SYMBOL
388 int evhttp_set_flags(struct evhttp *http, int flags);
389 
390 /* Request/Response functionality */
391 
400 EVENT2_EXPORT_SYMBOL
401 void evhttp_send_error(struct evhttp_request *req, int error,
402  const char *reason);
403 
417 EVENT2_EXPORT_SYMBOL
418 void evhttp_send_reply(struct evhttp_request *req, int code,
419  const char *reason, struct evbuffer *databuf);
420 
421 /* Low-level response interface, for streaming/chunked replies */
422 
437 EVENT2_EXPORT_SYMBOL
438 void evhttp_send_reply_start(struct evhttp_request *req, int code,
439  const char *reason);
440 
452 EVENT2_EXPORT_SYMBOL
453 void evhttp_send_reply_chunk(struct evhttp_request *req,
454  struct evbuffer *databuf);
455 
469 EVENT2_EXPORT_SYMBOL
470 void evhttp_send_reply_chunk_with_cb(struct evhttp_request *, struct evbuffer *,
471  void (*cb)(struct evhttp_connection *, void *), void *arg);
472 
478 EVENT2_EXPORT_SYMBOL
479 void evhttp_send_reply_end(struct evhttp_request *req);
480 
481 /*
482  * Interfaces for making requests
483  */
484 
493  EVHTTP_REQ_GET = 1 << 0,
494  EVHTTP_REQ_POST = 1 << 1,
495  EVHTTP_REQ_HEAD = 1 << 2,
496  EVHTTP_REQ_PUT = 1 << 3,
497  EVHTTP_REQ_DELETE = 1 << 4,
498  EVHTTP_REQ_OPTIONS = 1 << 5,
499  EVHTTP_REQ_TRACE = 1 << 6,
500  EVHTTP_REQ_CONNECT = 1 << 7,
501  EVHTTP_REQ_PATCH = 1 << 8
502 };
503 
505 enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE };
506 
523 EVENT2_EXPORT_SYMBOL
524 struct evhttp_connection *evhttp_connection_base_bufferevent_new(
525  struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port);
526 
530 EVENT2_EXPORT_SYMBOL
531 struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon);
532 
536 EVENT2_EXPORT_SYMBOL
537 struct evhttp *evhttp_connection_get_server(struct evhttp_connection *evcon);
538 
544 EVENT2_EXPORT_SYMBOL
545 struct evhttp_request *evhttp_request_new(
546  void (*cb)(struct evhttp_request *, void *), void *arg);
547 
555 EVENT2_EXPORT_SYMBOL
556 void evhttp_request_set_chunked_cb(struct evhttp_request *,
557  void (*cb)(struct evhttp_request *, void *));
558 
565 EVENT2_EXPORT_SYMBOL
566 void evhttp_request_set_header_cb(struct evhttp_request *,
567  int (*cb)(struct evhttp_request *, void *));
568 
599 };
607 EVENT2_EXPORT_SYMBOL
608 void evhttp_request_set_error_cb(struct evhttp_request *,
609  void (*)(enum evhttp_request_error, void *));
610 
623 EVENT2_EXPORT_SYMBOL
624 void evhttp_request_set_on_complete_cb(struct evhttp_request *req,
625  void (*cb)(struct evhttp_request *, void *), void *cb_arg);
626 
628 EVENT2_EXPORT_SYMBOL
629 void evhttp_request_free(struct evhttp_request *req);
630 
644 EVENT2_EXPORT_SYMBOL
645 struct evhttp_connection *evhttp_connection_base_new(
646  struct event_base *base, struct evdns_base *dnsbase,
647  const char *address, ev_uint16_t port);
648 
652 EVENT2_EXPORT_SYMBOL
653 void evhttp_connection_set_family(struct evhttp_connection *evcon,
654  int family);
655 
656 /* reuse connection address on retry */
657 #define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008
658 /* Try to read error, since server may already send and close
659  * connection, but if at that time we have some data to send then we
660  * can send get EPIPE and fail, while we can read that HTTP error. */
661 #define EVHTTP_CON_READ_ON_WRITE_ERROR 0x0010
662 /* @see EVHTTP_SERVER_LINGERING_CLOSE */
663 #define EVHTTP_CON_LINGERING_CLOSE 0x0020
664 /* Padding for public flags, @see EVHTTP_CON_* in http-internal.h */
665 #define EVHTTP_CON_PUBLIC_FLAGS_END 0x100000
666 
673 EVENT2_EXPORT_SYMBOL
674 int evhttp_connection_set_flags(struct evhttp_connection *evcon,
675  int flags);
676 
682 EVENT2_EXPORT_SYMBOL
683 void evhttp_request_own(struct evhttp_request *req);
684 
686 EVENT2_EXPORT_SYMBOL
687 int evhttp_request_is_owned(struct evhttp_request *req);
688 
695 EVENT2_EXPORT_SYMBOL
696 struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req);
697 
701 EVENT2_EXPORT_SYMBOL
702 struct event_base *evhttp_connection_get_base(struct evhttp_connection *req);
703 
704 EVENT2_EXPORT_SYMBOL
705 void evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon,
706  ev_ssize_t new_max_headers_size);
707 
708 EVENT2_EXPORT_SYMBOL
709 void evhttp_connection_set_max_body_size(struct evhttp_connection* evcon,
710  ev_ssize_t new_max_body_size);
711 
713 EVENT2_EXPORT_SYMBOL
714 void evhttp_connection_free(struct evhttp_connection *evcon);
715 
721 EVENT2_EXPORT_SYMBOL
722 void evhttp_connection_free_on_completion(struct evhttp_connection *evcon);
723 
725 EVENT2_EXPORT_SYMBOL
726 void evhttp_connection_set_local_address(struct evhttp_connection *evcon,
727  const char *address);
728 
730 EVENT2_EXPORT_SYMBOL
731 void evhttp_connection_set_local_port(struct evhttp_connection *evcon,
732  ev_uint16_t port);
733 
735 EVENT2_EXPORT_SYMBOL
736 void evhttp_connection_set_timeout(struct evhttp_connection *evcon,
737  int timeout_in_secs);
738 
741 EVENT2_EXPORT_SYMBOL
742 void evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon,
743  const struct timeval *tv);
744 
749 EVENT2_EXPORT_SYMBOL
750 void evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon,
751  const struct timeval *tv);
752 
754 EVENT2_EXPORT_SYMBOL
755 void evhttp_connection_set_retries(struct evhttp_connection *evcon,
756  int retry_max);
757 
759 EVENT2_EXPORT_SYMBOL
760 void evhttp_connection_set_closecb(struct evhttp_connection *evcon,
761  void (*)(struct evhttp_connection *, void *), void *);
762 
764 EVENT2_EXPORT_SYMBOL
765 void evhttp_connection_get_peer(struct evhttp_connection *evcon,
766  char **address, ev_uint16_t *port);
767 
774 EVENT2_EXPORT_SYMBOL
775 const struct sockaddr*
776 evhttp_connection_get_addr(struct evhttp_connection *evcon);
777 
791 EVENT2_EXPORT_SYMBOL
792 int evhttp_make_request(struct evhttp_connection *evcon,
793  struct evhttp_request *req,
794  enum evhttp_cmd_type type, const char *uri);
795 
809 EVENT2_EXPORT_SYMBOL
810 void evhttp_cancel_request(struct evhttp_request *req);
811 
815 struct evhttp_uri;
816 
818 EVENT2_EXPORT_SYMBOL
819 const char *evhttp_request_get_uri(const struct evhttp_request *req);
821 EVENT2_EXPORT_SYMBOL
822 const struct evhttp_uri *evhttp_request_get_evhttp_uri(const struct evhttp_request *req);
824 EVENT2_EXPORT_SYMBOL
825 enum evhttp_cmd_type evhttp_request_get_command(const struct evhttp_request *req);
826 
827 EVENT2_EXPORT_SYMBOL
828 int evhttp_request_get_response_code(const struct evhttp_request *req);
829 EVENT2_EXPORT_SYMBOL
830 const char * evhttp_request_get_response_code_line(const struct evhttp_request *req);
831 
833 EVENT2_EXPORT_SYMBOL
834 struct evkeyvalq *evhttp_request_get_input_headers(struct evhttp_request *req);
836 EVENT2_EXPORT_SYMBOL
837 struct evkeyvalq *evhttp_request_get_output_headers(struct evhttp_request *req);
839 EVENT2_EXPORT_SYMBOL
840 struct evbuffer *evhttp_request_get_input_buffer(struct evhttp_request *req);
842 EVENT2_EXPORT_SYMBOL
843 struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req);
848 EVENT2_EXPORT_SYMBOL
849 const char *evhttp_request_get_host(struct evhttp_request *req);
850 
851 /* Interfaces for dealing with HTTP headers */
852 
862 EVENT2_EXPORT_SYMBOL
863 const char *evhttp_find_header(const struct evkeyvalq *headers,
864  const char *key);
865 
874 EVENT2_EXPORT_SYMBOL
875 int evhttp_remove_header(struct evkeyvalq *headers, const char *key);
876 
886 EVENT2_EXPORT_SYMBOL
887 int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *value);
888 
894 EVENT2_EXPORT_SYMBOL
895 void evhttp_clear_headers(struct evkeyvalq *headers);
896 
897 /* Miscellaneous utility functions */
898 
899 
911 EVENT2_EXPORT_SYMBOL
912 char *evhttp_encode_uri(const char *str);
913 
928 EVENT2_EXPORT_SYMBOL
929 char *evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus);
930 
945 EVENT2_EXPORT_SYMBOL
946 char *evhttp_decode_uri(const char *uri);
947 
963 EVENT2_EXPORT_SYMBOL
964 char *evhttp_uridecode(const char *uri, int decode_plus,
965  size_t *size_out);
966 
986 EVENT2_EXPORT_SYMBOL
987 int evhttp_parse_query(const char *uri, struct evkeyvalq *headers);
988 
1006 EVENT2_EXPORT_SYMBOL
1007 int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers);
1008 
1020 EVENT2_EXPORT_SYMBOL
1021 char *evhttp_htmlescape(const char *html);
1022 
1026 EVENT2_EXPORT_SYMBOL
1027 struct evhttp_uri *evhttp_uri_new(void);
1028 
1033 EVENT2_EXPORT_SYMBOL
1034 void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags);
1035 
1038 EVENT2_EXPORT_SYMBOL
1039 const char *evhttp_uri_get_scheme(const struct evhttp_uri *uri);
1044 EVENT2_EXPORT_SYMBOL
1045 const char *evhttp_uri_get_userinfo(const struct evhttp_uri *uri);
1058 EVENT2_EXPORT_SYMBOL
1059 const char *evhttp_uri_get_host(const struct evhttp_uri *uri);
1061 EVENT2_EXPORT_SYMBOL
1062 int evhttp_uri_get_port(const struct evhttp_uri *uri);
1064 EVENT2_EXPORT_SYMBOL
1065 const char *evhttp_uri_get_path(const struct evhttp_uri *uri);
1068 EVENT2_EXPORT_SYMBOL
1069 const char *evhttp_uri_get_query(const struct evhttp_uri *uri);
1072 EVENT2_EXPORT_SYMBOL
1073 const char *evhttp_uri_get_fragment(const struct evhttp_uri *uri);
1074 
1077 EVENT2_EXPORT_SYMBOL
1078 int evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme);
1081 EVENT2_EXPORT_SYMBOL
1082 int evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo);
1085 EVENT2_EXPORT_SYMBOL
1086 int evhttp_uri_set_host(struct evhttp_uri *uri, const char *host);
1089 EVENT2_EXPORT_SYMBOL
1090 int evhttp_uri_set_port(struct evhttp_uri *uri, int port);
1093 EVENT2_EXPORT_SYMBOL
1094 int evhttp_uri_set_path(struct evhttp_uri *uri, const char *path);
1098 EVENT2_EXPORT_SYMBOL
1099 int evhttp_uri_set_query(struct evhttp_uri *uri, const char *query);
1103 EVENT2_EXPORT_SYMBOL
1104 int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment);
1105 
1140 EVENT2_EXPORT_SYMBOL
1141 struct evhttp_uri *evhttp_uri_parse_with_flags(const char *source_uri,
1142  unsigned flags);
1143 
1156 #define EVHTTP_URI_NONCONFORMANT 0x01
1157 
1159 EVENT2_EXPORT_SYMBOL
1160 struct evhttp_uri *evhttp_uri_parse(const char *source_uri);
1161 
1169 EVENT2_EXPORT_SYMBOL
1170 void evhttp_uri_free(struct evhttp_uri *uri);
1171 
1185 EVENT2_EXPORT_SYMBOL
1186 char *evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit);
1187 
1188 #ifdef __cplusplus
1189 }
1190 #endif
1191 
1192 #endif /* EVENT2_HTTP_H_INCLUDED_ */
EVENT2_EXPORT_SYMBOL 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...
EVENT2_EXPORT_SYMBOL void evhttp_request_set_error_cb(struct evhttp_request *, void(*)(enum evhttp_request_error, void *))
Set a callback for errors.
EVENT2_EXPORT_SYMBOL void evhttp_request_own(struct evhttp_request *req)
Takes ownership of the request object.
EVENT2_EXPORT_SYMBOL const char * evhttp_find_header(const struct evkeyvalq *headers, const char *key)
Finds the value belonging to a header.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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...
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct bufferevent * evhttp_connection_get_bufferevent(struct evhttp_connection *evcon)
Return the bufferevent that an evhttp_connection is using.
EVENT2_EXPORT_SYMBOL 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.
The evhttp_cancel_request() called on this request.
Definition: http.h:594
EVENT2_EXPORT_SYMBOL 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...
EVENT2_EXPORT_SYMBOL void evhttp_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf)
Send an HTML reply to the client.
EVENT2_EXPORT_SYMBOL struct event_base * evhttp_connection_get_base(struct evhttp_connection *req)
Returns the underlying event_base for this connection.
EVENT2_EXPORT_SYMBOL void evhttp_send_reply_chunk_with_cb(struct evhttp_request *, struct evbuffer *, void(*cb)(struct evhttp_connection *, void *), void *arg)
Send another data chunk as part of an ongoing chunked reply.
EVENT2_EXPORT_SYMBOL int evhttp_remove_virtual_host(struct evhttp *http, struct evhttp *vhost)
Removes a virtual host from the http server.
EVENT2_EXPORT_SYMBOL struct evhttp_uri * evhttp_uri_new(void)
Return a new empty evhttp_uri with no fields set.
EVENT2_EXPORT_SYMBOL struct evhttp * evhttp_new(struct event_base *base)
Create a new HTTP server.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evbuffer * evhttp_request_get_input_buffer(struct evhttp_request *req)
Returns the input buffer.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evhttp_uri * evhttp_uri_parse(const char *source_uri)
Alias for evhttp_uri_parse_with_flags(source_uri, 0)
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_retries(struct evhttp_connection *evcon, int retry_max)
Sets the retry limit for this connection - -1 repeats indefinitely.
EVENT2_EXPORT_SYMBOL int evhttp_request_is_owned(struct evhttp_request *req)
Returns 1 if the request is owned by the user.
EVENT2_EXPORT_SYMBOL char * evhttp_encode_uri(const char *str)
Helper function to encode a string for inclusion in a URI.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t port)
Binds an HTTP server on the specified address and port.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_local_address(struct evhttp_connection *evcon, const char *address)
sets the ip address from which http connections are made
EVENT2_EXPORT_SYMBOL char * evhttp_htmlescape(const char *html)
Escape HTML character entities in a string.
EVENT2_EXPORT_SYMBOL char * evhttp_decode_uri(const char *uri)
Helper function to sort of decode a URI-encoded string.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_family(struct evhttp_connection *evcon, int family)
Set family hint for DNS requests.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evhttp_add_header(struct evkeyvalq *headers, const char *key, const char *value)
Adds a header to a list of existing headers.
EVENT2_EXPORT_SYMBOL char * evhttp_uriencode(const char *str, ev_ssize_t size, int space_to_plus)
As evhttp_encode_uri, but if &#39;size&#39; is nonnegative, treat the string as being &#39;size&#39; bytes long...
EVENT2_EXPORT_SYMBOL struct evkeyvalq * evhttp_request_get_input_headers(struct evhttp_request *req)
Returns the input headers.
EVENT2_EXPORT_SYMBOL void evhttp_set_timeout(struct evhttp *http, int timeout_in_secs)
Set the timeout for an HTTP request.
EVENT2_EXPORT_SYMBOL void evhttp_request_set_chunked_cb(struct evhttp_request *, void(*cb)(struct evhttp_request *, void *))
Enable delivery of chunks to requestor.
EVENT2_EXPORT_SYMBOL void evhttp_send_reply_end(struct evhttp_request *req)
Complete a chunked reply, freeing the request as appropriate.
EVENT2_EXPORT_SYMBOL int evhttp_remove_server_alias(struct evhttp *http, const char *alias)
Remove a server alias from an http object.
EVENT2_EXPORT_SYMBOL void evhttp_cancel_request(struct evhttp_request *req)
Cancels a pending HTTP request.
EVENT2_EXPORT_SYMBOL int evhttp_connection_set_flags(struct evhttp_connection *evcon, int flags)
Set connection flags.
EVENT2_EXPORT_SYMBOL void evhttp_request_set_header_cb(struct evhttp_request *, int(*cb)(struct evhttp_request *, void *))
Register callback for additional parsing of request headers.
evhttp_request_kind
a request object can represent either a request or a reply
Definition: http.h:505
EVENT2_EXPORT_SYMBOL struct evhttp_connection * evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, const char *address, ev_uint16_t port)
Create and return a connection object that can be used to for making HTTP requests.
EVENT2_EXPORT_SYMBOL void evhttp_request_free(struct evhttp_request *req)
Frees the request object and removes associated events.
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:310
EVENT2_EXPORT_SYMBOL void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags)
Changes the flags set on a given URI.
EVENT2_EXPORT_SYMBOL void evhttp_set_bevcb(struct evhttp *http, struct bufferevent *(*cb)(struct event_base *, void *), void *arg)
Set a callback used to create new bufferevents for connections to a given evhttp object.
EVENT2_EXPORT_SYMBOL void evhttp_uri_free(struct evhttp_uri *uri)
Free all memory allocated for a parsed uri.
EVENT2_EXPORT_SYMBOL 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...
EVENT2_EXPORT_SYMBOL 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 ...
EVENT2_EXPORT_SYMBOL const struct evhttp_uri * evhttp_request_get_evhttp_uri(const struct evhttp_request *req)
Returns the request URI (parsed)
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evhttp_request_set_on_complete_cb(struct evhttp_request *req, void(*cb)(struct evhttp_request *, void *), void *cb_arg)
Set a callback to be called on request completion of evhttp_send_* function.
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:97
EVENT2_EXPORT_SYMBOL int evhttp_add_virtual_host(struct evhttp *http, const char *pattern, struct evhttp *vhost)
Adds a virtual host to the http server.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evconnlistener * evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound)
Return the listener used to implement a bound socket.
EVENT2_EXPORT_SYMBOL void evhttp_clear_headers(struct evkeyvalq *headers)
Removes all headers from the header list.
evhttp_request_error
The different error types supported by evhttp.
Definition: http.h:574
EVENT2_EXPORT_SYMBOL const char * evhttp_request_get_uri(const struct evhttp_request *req)
Returns the request URI.
Common convenience functions for cross-platform portability and related socket manipulations.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_closecb(struct evhttp_connection *evcon, void(*)(struct evhttp_connection *, void *), void *)
Set a callback for connection close.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evhttp_free(struct evhttp *http)
Free the previously created HTTP server.
EVENT2_EXPORT_SYMBOL int evhttp_remove_header(struct evkeyvalq *headers, const char *key)
Removes a header from a list of existing headers.
EVENT2_EXPORT_SYMBOL void evhttp_set_default_content_type(struct evhttp *http, const char *content_type)
Set the value to use for the Content-Type header when none was provided.
Error while reading header, or invalid header.
Definition: http.h:586
EVENT2_EXPORT_SYMBOL struct evkeyvalq * evhttp_request_get_output_headers(struct evhttp_request *req)
Returns the output headers.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon, const struct timeval *tv)
Sets the delay before retrying requests on this connection.
EVENT2_EXPORT_SYMBOL void evhttp_send_reply_start(struct evhttp_request *req, int code, const char *reason)
Initiate a reply that uses Transfer-Encoding chunked.
EVENT2_EXPORT_SYMBOL struct evbuffer * evhttp_request_get_output_buffer(struct evhttp_request *req)
Returns the output buffer.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_timeout(struct evhttp_connection *evcon, int timeout_in_secs)
Sets the timeout in seconds for events related to this connection.
EVENT2_EXPORT_SYMBOL const char * evhttp_request_get_host(struct evhttp_request *req)
Returns the host associated with the request.
EVENT2_EXPORT_SYMBOL struct evhttp_connection * evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent *bev, const char *address, ev_uint16_t port)
Create and return a connection object that can be used to for making HTTP requests.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evhttp_foreach_bound_socket(struct evhttp *http, evhttp_bound_socket_foreach_fn *function, void *argument)
Applies the function specified in the first argument to all evhttp_bound_sockets associated with "htt...
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evhttp_set_flags(struct evhttp *http, int flags)
Set connection flags for HTTP server.
EVENT2_EXPORT_SYMBOL const struct sockaddr * evhttp_connection_get_addr(struct evhttp_connection *evcon)
Get the remote address associated with this connection.
EVENT2_EXPORT_SYMBOL enum evhttp_cmd_type evhttp_request_get_command(const struct evhttp_request *req)
Returns the request command.
EVENT2_EXPORT_SYMBOL void evhttp_set_max_headers_size(struct evhttp *http, ev_ssize_t max_headers_size)
XXX Document.
EVENT2_EXPORT_SYMBOL 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.
An opaque type for handling buffered IO.
Definition: bufferevent.h:113
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evhttp_connection * evhttp_request_get_connection(struct evhttp_request *req)
Returns the connection object associated with the request or NULL.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_local_port(struct evhttp_connection *evcon, ev_uint16_t port)
sets the local port from which http connections are made
EVENT2_EXPORT_SYMBOL void evhttp_connection_free_on_completion(struct evhttp_connection *evcon)
Disowns a given connection object.
EVENT2_EXPORT_SYMBOL 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.
EOF reached.
Definition: http.h:582
EVENT2_EXPORT_SYMBOL void evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon, const struct timeval *tv)
Sets the timeout for events related to this connection.
EVENT2_EXPORT_SYMBOL char * evhttp_uridecode(const char *uri, int decode_plus, size_t *size_out)
Helper function to decode a URI-escaped string or HTTP parameter.
EVENT2_EXPORT_SYMBOL struct evhttp * evhttp_connection_get_server(struct evhttp_connection *evcon)
Return the HTTP server associated with this connection, or NULL.
Body is greater then evhttp_connection_set_max_body_size()
Definition: http.h:598
EVENT2_EXPORT_SYMBOL int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd)
Makes an HTTP server accept connections on the specified socket.
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:217
EVENT2_EXPORT_SYMBOL int evhttp_add_server_alias(struct evhttp *http, const char *alias)
Add a server alias to an http object.
EVENT2_EXPORT_SYMBOL int evhttp_parse_query(const char *uri, struct evkeyvalq *headers)
Helper function to parse out arguments in a query.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evhttp_del_cb(struct evhttp *, const char *)
Removes the callback for a specified URI.
EVENT2_EXPORT_SYMBOL void evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
Send another data chunk as part of an ongoing chunked reply.
evhttp_cmd_type
The different request types supported by evhttp.
Definition: http.h:492
EVENT2_EXPORT_SYMBOL void evhttp_connection_free(struct evhttp_connection *evcon)
Frees an http connection.
Error encountered while reading or writing.
Definition: http.h:590
EVENT2_EXPORT_SYMBOL void evhttp_set_max_body_size(struct evhttp *http, ev_ssize_t max_body_size)
XXX Document.
EVENT2_EXPORT_SYMBOL void evhttp_set_timeout_tv(struct evhttp *http, const struct timeval *tv)
Set the timeout for an HTTP request.
EVENT2_EXPORT_SYMBOL void evhttp_send_error(struct evhttp_request *req, int error, const char *reason)
Send an HTML error message to the client.
Timeout reached, also.
Definition: http.h:578