deimos.event2.http

Undocumented in source.

Public Imports

deimos.event2.util
public import deimos.event2.util;

Members

Aliases

evbuffer
alias evbuffer = deimos.event2._opaque_structs.evbuffer
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
event_base
alias event_base = deimos.event2._opaque_structs.event_base
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Enums

evhttp_cmd_type
enum evhttp_cmd_type

The different request types supported by evhttp. These are as specified in RFC2616, except for PATCH which is specified by RFC5789.

evhttp_request_kind
enum evhttp_request_kind

a request object can represent either a request or a reply

Functions

evhttp_accept_socket
int evhttp_accept_socket(evhttp* http, evutil_socket_t fd)

Makes an HTTP server accept connections on the specified socket.

evhttp_accept_socket_with_handle
evhttp_bound_socket* evhttp_accept_socket_with_handle(evhttp* http, evutil_socket_t fd)

Like evhttp_accept_socket(), but returns a handle for referencing the socket.

evhttp_add_header
int evhttp_add_header(evkeyvalq* headers, const(char)* key, const(char)* value)

Adds a header to a list of existing headers.

evhttp_add_server_alias
int evhttp_add_server_alias(evhttp* http, const(char)* alias_)

Add a server alias to an http object. The http object can be a virtual host or the main server.

evhttp_add_virtual_host
int evhttp_add_virtual_host(evhttp* http, const(char)* pattern, evhttp* vhost)

Adds a virtual host to the http server.

evhttp_bind_listener
evhttp_bound_socket* evhttp_bind_listener(evhttp* http, evconnlistener* listener)

The most low-level evhttp_bind/accept method: takes an evconnlistener, and returns an evhttp_bound_socket. The listener will be freed when the bound socket is freed.

evhttp_bind_socket
int evhttp_bind_socket(evhttp* http, const(char)* address, ev_uint16_t port)

Binds an HTTP server on the specified address and port.

evhttp_bind_socket_with_handle
evhttp_bound_socket* evhttp_bind_socket_with_handle(evhttp* http, const(char)* address, ev_uint16_t port)

Like evhttp_bind_socket(), but returns a handle for referencing the socket.

evhttp_bound_socket_get_fd
evutil_socket_t evhttp_bound_socket_get_fd(evhttp_bound_socket* bound_socket)

Get the raw file descriptor referenced by an evhttp_bound_socket.

evhttp_bound_socket_get_listener
evconnlistener* evhttp_bound_socket_get_listener(evhttp_bound_socket* bound)

Return the listener used to implement a bound socket.

evhttp_cancel_request
void evhttp_cancel_request(evhttp_request* req)

Cancels a pending HTTP request.

evhttp_clear_headers
void evhttp_clear_headers(evkeyvalq* headers)

Removes all headers from the header list.

evhttp_connection_base_new
evhttp_connection* evhttp_connection_base_new(event_base* base, evdns_base* dnsbase, const(char)* address, ushort port)

A connection object that can be used to for making HTTP requests. The connection object tries to resolve address and establish the connection when it is given an http request object.

evhttp_connection_free
void evhttp_connection_free(evhttp_connection* evcon)

Frees an http connection

evhttp_connection_get_base
event_base* evhttp_connection_get_base(evhttp_connection* req)

Returns the underlying event_base for this connection

evhttp_connection_get_peer
void evhttp_connection_get_peer(evhttp_connection* evcon, char** address, ev_uint16_t* port)

Get the remote address and port associated with this connection.

evhttp_connection_set_closecb
void evhttp_connection_set_closecb(evhttp_connection* evcon, ExternC!(void function(evhttp_connection*, void*)) , void* )

Set a callback for connection close.

evhttp_connection_set_local_address
void evhttp_connection_set_local_address(evhttp_connection* evcon, const(char)* address)

sets the ip address from which http connections are made

evhttp_connection_set_local_port
void evhttp_connection_set_local_port(evhttp_connection* evcon, ev_uint16_t port)

sets the local port from which http connections are made

evhttp_connection_set_max_body_size
void evhttp_connection_set_max_body_size(evhttp_connection* evcon, ev_ssize_t new_max_body_size)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_connection_set_max_headers_size
void evhttp_connection_set_max_headers_size(evhttp_connection* evcon, ev_ssize_t new_max_headers_size)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_connection_set_retries
void evhttp_connection_set_retries(evhttp_connection* evcon, int retry_max)

Sets the retry limit for this connection - -1 repeats indefinitely

evhttp_connection_set_timeout
void evhttp_connection_set_timeout(evhttp_connection* evcon, int timeout_in_secs)

Sets the timeout for events related to this connection

evhttp_decode_uri
char* evhttp_decode_uri(const(char)* uri)

Helper function to sort of decode a URI-encoded string. Unlike evhttp_get_decoded_uri, it decodes all plus characters that appear _after_ the first question mark character, but no plusses that occur before. This is not a good way to decode URIs in whole or in part.

evhttp_del_accept_socket
void evhttp_del_accept_socket(evhttp* http, evhttp_bound_socket* bound_socket)

Makes an HTTP server stop accepting connections on the specified socket

evhttp_del_cb
int evhttp_del_cb(evhttp* , const(char)* )

Removes the callback for a specified URI

evhttp_encode_uri
char* evhttp_encode_uri(const(char)* str)

Helper function to encode a string for inclusion in a URI. All characters are replaced by their hex-escaped (%22) equivalents, except for characters explicitly unreserved by RFC3986 -- that is, ASCII alphanumeric characters, hyphen, dot, underscore, and tilde.

evhttp_find_header
const(char)* evhttp_find_header(const(evkeyvalq)* headers, const(char)* key)

Finds the value belonging to a header.

evhttp_free
void evhttp_free(evhttp* http)

Free the previously created HTTP server.

evhttp_htmlescape
char* evhttp_htmlescape(const(char)* html)

Escape HTML character entities in a string.

evhttp_make_request
int evhttp_make_request(evhttp_connection* evcon, evhttp_request* req, evhttp_cmd_type type, const(char)* uri)

Make an HTTP request over the specified connection.

evhttp_new
evhttp* evhttp_new(event_base* base)

Create a new HTTP server.

evhttp_parse_query
int evhttp_parse_query(const(char)* uri, evkeyvalq* headers)

Helper function to parse out arguments in a query.

evhttp_parse_query_str
int evhttp_parse_query_str(const(char)* uri, evkeyvalq* headers)

Helper function to parse out arguments from the query portion of an HTTP URI.

evhttp_remove_header
int evhttp_remove_header(evkeyvalq* headers, const(char)* key)

Removes a header from a list of existing headers.

evhttp_remove_server_alias
int evhttp_remove_server_alias(evhttp* http, const(char)* alias_)

Remove a server alias from an http object.

evhttp_remove_virtual_host
int evhttp_remove_virtual_host(evhttp* http, evhttp* vhost)

Removes a virtual host from the http server.

evhttp_request_free
void evhttp_request_free(evhttp_request* req)

Frees the request object and removes associated events.

evhttp_request_get_command
evhttp_cmd_type evhttp_request_get_command(const(evhttp_request)* req)

Returns the request command

evhttp_request_get_connection
evhttp_connection* evhttp_request_get_connection(evhttp_request* req)

Returns the connection object associated with the request or NULL

evhttp_request_get_evhttp_uri
const(evhttp_uri)* evhttp_request_get_evhttp_uri(const(evhttp_request)* req)

Returns the request URI (parsed)

evhttp_request_get_host
const(char)* evhttp_request_get_host(evhttp_request* req)

Returns the host associated with the request. If a client sends an absolute URI, the host part of that is preferred. Otherwise, the input headers are searched for a Host: header. NULL is returned if no absolute URI or Host: header is provided.

evhttp_request_get_input_buffer
evbuffer* evhttp_request_get_input_buffer(evhttp_request* req)

Returns the input buffer

evhttp_request_get_input_headers
evkeyvalq* evhttp_request_get_input_headers(evhttp_request* req)

Returns the input headers

evhttp_request_get_output_buffer
evbuffer* evhttp_request_get_output_buffer(evhttp_request* req)

Returns the output buffer

evhttp_request_get_output_headers
evkeyvalq* evhttp_request_get_output_headers(evhttp_request* req)

Returns the output headers

evhttp_request_get_response_code
int evhttp_request_get_response_code(const(evhttp_request)* req)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_request_get_uri
const(char)* evhttp_request_get_uri(const(evhttp_request)* req)

Returns the request URI

evhttp_request_is_owned
int evhttp_request_is_owned(evhttp_request* req)

Returns 1 if the request is owned by the user

evhttp_request_new
evhttp_request* evhttp_request_new(ExternC!(void function(evhttp_request*, void*)) cb, void* arg)

Creates a new request object that needs to be filled in with the request parameters. The callback is executed when the request completed or an error occurred.

evhttp_request_own
void evhttp_request_own(evhttp_request* req)

Takes ownership of the request object

evhttp_request_set_chunked_cb
void evhttp_request_set_chunked_cb(evhttp_request* , ExternC!(void function(evhttp_request*, void*)) cb)

Enable delivery of chunks to requestor. @param cb will be called after every read of data with the same argument as the completion callback. Will never be called on an empty response. May drain the input buffer; it will be drained automatically on return.

evhttp_send_error
void evhttp_send_error(evhttp_request* req, int error, const(char)* reason)

Send an HTML error message to the client.

evhttp_send_reply
void evhttp_send_reply(evhttp_request* req, int code, const(char)* reason, evbuffer* databuf)

Send an HTML reply to the client.

evhttp_send_reply_chunk
void evhttp_send_reply_chunk(evhttp_request* req, evbuffer* databuf)

Send another data chunk as part of an ongoing chunked reply.

evhttp_send_reply_end
void evhttp_send_reply_end(evhttp_request* req)

Complete a chunked reply, freeing the request as appropriate.

evhttp_send_reply_start
void evhttp_send_reply_start(evhttp_request* req, int code, const(char)* reason)

Initiate a reply that uses Transfer-Encoding chunked.

evhttp_set_allowed_methods
void evhttp_set_allowed_methods(evhttp* http, ev_uint16_t methods)

Sets the what HTTP methods are supported in requests accepted by this server, and passed to user callbacks.

evhttp_set_cb
int evhttp_set_cb(evhttp* http, const(char)* path, ExternC!(void function(evhttp_request*, void*)) cb, void* cb_arg)

Set a callback for a specified URI

evhttp_set_gencb
void evhttp_set_gencb(evhttp* http, ExternC!(void function(evhttp_request*, void*)) cb, void* arg)

Set a callback for all requests that are not caught by specific callbacks

evhttp_set_max_body_size
void evhttp_set_max_body_size(evhttp* http, ev_ssize_t max_body_size)

XXX Document.

evhttp_set_max_headers_size
void evhttp_set_max_headers_size(evhttp* http, ev_ssize_t max_headers_size)

XXX Document.

evhttp_set_timeout
void evhttp_set_timeout(evhttp* http, int timeout_in_secs)

Set the timeout for an HTTP request.

evhttp_uri_free
void evhttp_uri_free(evhttp_uri* uri)

Free all memory allocated for a parsed uri. Only use this for URIs generated by evhttp_uri_parse.

evhttp_uri_get_fragment
const(char)* evhttp_uri_get_fragment(const(evhttp_uri)* uri)

Return the fragment part of an evhttp_uri (excluding the leading "#"), * or NULL if it has no fragment set

evhttp_uri_get_host
const(char)* evhttp_uri_get_host(const(evhttp_uri)* uri)

Return the host part of an evhttp_uri, or NULL if it has no host set. The host may either be a regular hostname (conforming to the RFC 3986 "regname" production), or an IPv4 address, or the empty string, or a bracketed IPv6 address, or a bracketed 'IP-Future' address.

evhttp_uri_get_path
const(char)* evhttp_uri_get_path(const(evhttp_uri)* uri)

Return the path part of an evhttp_uri, or NULL if it has no path set

evhttp_uri_get_port
int evhttp_uri_get_port(const(evhttp_uri)* uri)

Return the port part of an evhttp_uri, or -1 if there is no port set.

evhttp_uri_get_query
const(char)* evhttp_uri_get_query(const(evhttp_uri)* uri)

Return the query part of an evhttp_uri (excluding the leading "?"), or * NULL if it has no query set

evhttp_uri_get_scheme
const(char)* evhttp_uri_get_scheme(const(evhttp_uri)* uri)

Return the scheme of an evhttp_uri, or NULL if there is no scheme has * been set and the evhttp_uri contains a Relative-Ref.

evhttp_uri_get_userinfo
const(char)* evhttp_uri_get_userinfo(const(evhttp_uri)* uri)

Return the userinfo part of an evhttp_uri, or NULL if it has no userinfo set.

evhttp_uri_join
char* evhttp_uri_join(evhttp_uri* uri, char* buf, size_t limit)

Join together the uri parts from parsed data to form a URI-Reference.

evhttp_uri_new
evhttp_uri* evhttp_uri_new()

Return a new empty evhttp_uri with no fields set.

evhttp_uri_parse
evhttp_uri* evhttp_uri_parse(const(char)* source_uri)

Alias for evhttp_uri_parse_with_flags(source_uri, 0)

evhttp_uri_parse_with_flags
evhttp_uri* evhttp_uri_parse_with_flags(const(char)* source_uri, uint flags)

Helper function to parse a URI-Reference as specified by RFC3986.

evhttp_uri_set_flags
void evhttp_uri_set_flags(evhttp_uri* uri, uint flags)

Changes the flags set on a given URI. See EVHTTP_URI_* for a list of flags.

evhttp_uri_set_fragment
int evhttp_uri_set_fragment(evhttp_uri* uri, const(char)* fragment)

Set the fragment of an evhttp_uri, or clear the fragment if fragment==NULL. * The fragment should not include a leading "#". * Returns 0 on success, -1 if fragment is not well-formed.

evhttp_uri_set_host
int evhttp_uri_set_host(evhttp_uri* uri, const(char)* host)

Set the host of an evhttp_uri, or clear the host if host==NULL. * Returns 0 on success, -1 if host is not well-formed.

evhttp_uri_set_path
int evhttp_uri_set_path(evhttp_uri* uri, const(char)* path)

Set the path of an evhttp_uri, or clear the path if path==NULL. * Returns 0 on success, -1 if path is not well-formed.

evhttp_uri_set_port
int evhttp_uri_set_port(evhttp_uri* uri, int port)

Set the port of an evhttp_uri, or clear the port if port==-1. * Returns 0 on success, -1 if port is not well-formed.

evhttp_uri_set_query
int evhttp_uri_set_query(evhttp_uri* uri, const(char)* query)

Set the query of an evhttp_uri, or clear the query if query==NULL. * The query should not include a leading "?". * Returns 0 on success, -1 if query is not well-formed.

evhttp_uri_set_scheme
int evhttp_uri_set_scheme(evhttp_uri* uri, const(char)* scheme)

Set the scheme of an evhttp_uri, or clear the scheme if scheme==NULL. * Returns 0 on success, -1 if scheme is not well-formed.

evhttp_uri_set_userinfo
int evhttp_uri_set_userinfo(evhttp_uri* uri, const(char)* userinfo)

Set the userinfo of an evhttp_uri, or clear the userinfo if userinfo==NULL. * Returns 0 on success, -1 if userinfo is not well-formed.

evhttp_uridecode
char* evhttp_uridecode(const(char)* uri, int decode_plus, size_t* size_out)

Helper function to decode a URI-escaped string or HTTP parameter.

evhttp_uriencode
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. This allows you to encode strings that may contain 0-valued bytes.

Manifest constants

EVHTTP_URI_NONCONFORMANT
enum EVHTTP_URI_NONCONFORMANT;

Tolerate URIs that do not conform to RFC3986.

HTTP_BADMETHOD
enum HTTP_BADMETHOD;

< method not allowed for this uri

HTTP_BADREQUEST
enum HTTP_BADREQUEST;

< invalid http request was made

HTTP_ENTITYTOOLARGE
enum HTTP_ENTITYTOOLARGE;

<

HTTP_EXPECTATIONFAILED
enum HTTP_EXPECTATIONFAILED;

< we can't handle this expectation

HTTP_INTERNAL
enum HTTP_INTERNAL;

< internal error

HTTP_MOVEPERM
enum HTTP_MOVEPERM;

< the uri moved permanently

HTTP_MOVETEMP
enum HTTP_MOVETEMP;

< the uri moved temporarily

HTTP_NOCONTENT
enum HTTP_NOCONTENT;

< request does not have content

HTTP_NOTFOUND
enum HTTP_NOTFOUND;

< could not find content for uri

HTTP_NOTIMPLEMENTED
enum HTTP_NOTIMPLEMENTED;

< not implemented

HTTP_NOTMODIFIED
enum HTTP_NOTMODIFIED;

< page was not modified from last

HTTP_OK
enum HTTP_OK;

@file event2/http.h * * Basic support for HTTP serving. * * As Libevent is a library for dealing with event notification and most * interesting applications are networked today, I have often found the * need to write HTTP code. The following prototypes and definitions provide * an application with a minimal interface for making HTTP requests and for * creating a very simple HTTP server. *//**< request completed ok

HTTP_SERVUNAVAIL
enum HTTP_SERVUNAVAIL;

< the server is not available

Structs

evconnlistener
struct evconnlistener
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evdns_base
struct evdns_base
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp
struct evhttp
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_bound_socket
struct evhttp_bound_socket
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_connection
struct evhttp_connection
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_request
struct evhttp_request
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
evhttp_uri
struct evhttp_uri

A structure to hold a parsed URI or Relative-Ref conforming to RFC3986.

evkeyvalq
struct evkeyvalq
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Meta