libonion
|
Functions | |
onion_connection_status | onion_shortcut_response (const char *response, int code, onion_request *req, onion_response *res) |
Shortcut for fast responses, like errors.Prepares a fast response. You pass only the request, the text and the code, and it do the full response object and sends the data. | |
onion_connection_status | onion_shortcut_response_extra_headers (const char *response, int code, onion_request *req, onion_response *res,...) |
Shortcut for fast responses, like errors, with extra headersPrepares a fast response. You pass only the request, the text and the code, and it do the full response object and sends the data. | |
onion_connection_status | onion_shortcut_redirect (const char *newurl, onion_request *req, onion_response *res) |
Shortcut to ease a redirect.It can be used directly as a handler, or be called from a handler. | |
onion_connection_status | onion_shortcut_response_file (const char *filename, onion_request *request, onion_response *res) |
This shortcut returns the given file contents.This is the recomended way to send static files; it even can use sendfile Linux call if suitable. | |
onion_connection_status | onion_shortcut_response_json (onion_dict *d, onion_request *req, onion_response *res) |
Shortcut to answer some json dataIt converts to json the passed dict and returns it. The dict is freed before returning. | |
void | onion_shortcut_date_string (time_t t, char *dest) |
Transforms a time_t to a RFC 822 date stringThis date format is the standard in HTTP protocol as RFC 2616, section 3.3.1. | |
void | onion_shortcut_date_string_iso (time_t t, char *dest) |
Transforms a time_t to a ISO date stringThe dest pointer must be at least 21 bytes long as thats the maximum size of the date. | |
void | onion_shortcut_etag (struct stat *st, char etag[32]) |
Unifies the creation of etags.Just now its a very simple one, based on the size and date. | |
int | onion_shortcut_rename (const char *orig, const char *dest) |
Moves a file to another locationIt takes care if it can be a simple rename or must copy and remove old. |
Variables | |
int | onion_use_sendfile = -1 |
void onion_shortcut_date_string | ( | time_t | t, |
char * | dest | ||
) |
Transforms a time_t to a RFC 822 date stringThis date format is the standard in HTTP protocol as RFC 2616, section 3.3.1.
Shortcut to return the date in "RFC 822 / section 5, 4 digit years" date format.
The dest pointer must be at least 32 bytes long as thats the maximum size of the date.
Referenced by onion_webdav_write_props().
void onion_shortcut_date_string_iso | ( | time_t | t, |
char * | dest | ||
) |
Transforms a time_t to a ISO date stringThe dest pointer must be at least 21 bytes long as thats the maximum size of the date.
Shortcut to return the date in ISO format.
Referenced by onion_webdav_write_props().
void onion_shortcut_etag | ( | struct stat * | st, |
char | etag[32] | ||
) |
Unifies the creation of etags.Just now its a very simple one, based on the size and date.
Shortcut to return the date in time_t from a user given date TODO.
References ONION_DEBUG0.
Referenced by onion_shortcut_response_file(), and onion_webdav_write_props().
onion_connection_status onion_shortcut_redirect | ( | const char * | newurl, |
onion_request * | req, | ||
onion_response * | res | ||
) |
Shortcut to ease a redirect.It can be used directly as a handler, or be called from a handler.
Shortcut for fast redirect. It tells the browser to look somewhere else.
The browser message is fixed; if need more flexibility, create your own redirector.
References HTTP_REDIRECT, and onion_shortcut_response_extra_headers().
int onion_shortcut_rename | ( | const char * | orig, |
const char * | dest | ||
) |
Moves a file to another locationIt takes care if it can be a simple rename or must copy and remove old.
Moves a file to another location.
References ONION_DEBUG0, and ONION_ERROR.
Referenced by onion_webdav_move(), and onion_webdav_put().
onion_connection_status onion_shortcut_response | ( | const char * | response, |
int | code, | ||
onion_request * | req, | ||
onion_response * | res | ||
) |
Shortcut for fast responses, like errors.Prepares a fast response. You pass only the request, the text and the code, and it do the full response object and sends the data.
Shortcut for fast responses, like errors.
References onion_shortcut_response_extra_headers().
Referenced by onion_webdav_delete(), onion_webdav_handler(), onion_webdav_mkcol(), onion_webdav_move(), onion_webdav_propfind(), and onion_webdav_put().
onion_connection_status onion_shortcut_response_extra_headers | ( | const char * | response, |
int | code, | ||
onion_request * | req, | ||
onion_response * | res, | ||
... | |||
) |
Shortcut for fast responses, like errors, with extra headersPrepares a fast response. You pass only the request, the text and the code, and it do the full response object and sends the data.
Shortcut for fast responses, like errors, with extra headers.
On this version you also pass a NULL terminated list of headers, in key, value pairs.
References OCS_PROCESSED, onion_response_t::onion_response_set_code(), onion_response_t::onion_response_set_header(), onion_response_t::onion_response_set_length(), onion_response_t::onion_response_write(), and onion_response_t::onion_response_write_headers().
Referenced by onion_shortcut_redirect(), onion_shortcut_response(), and onion_shortcut_response_json().
onion_connection_status onion_shortcut_response_file | ( | const char * | filename, |
onion_request * | request, | ||
onion_response * | res | ||
) |
This shortcut returns the given file contents.This is the recomended way to send static files; it even can use sendfile Linux call if suitable.
Shortcut for response a static file on disk.
It does no security checks, so caller must be security aware.
References onion_request_t::connection, onion_request_t::fd, HTTP_NOT_MODIFIED, HTTP_PARTIAL_CONTENT, onion_request_t::listen_point, O_CLOEXEC, OCS_INTERNAL_ERROR, OCS_NOT_PROCESSED, OCS_PROCESSED, ONION_DEBUG, ONION_DEBUG0, ONION_ERROR, onion_http_t::onion_http_write(), onion_mime_get(), onion_request_t::onion_request_get_flags(), onion_request_t::onion_request_get_header(), onion_response_t::onion_response_set_code(), onion_response_t::onion_response_set_header(), onion_response_t::onion_response_set_length(), onion_response_t::onion_response_write(), onion_response_t::onion_response_write_headers(), onion_shortcut_etag(), onion_use_sendfile, ONION_WARNING, OR_HEAD, onion_response_t::sent_bytes, onion_response_t::sent_bytes_total, and onion_listen_point_t::write.
Referenced by onion_handler_export_local_handler(), and onion_webdav_get().
onion_connection_status onion_shortcut_response_json | ( | onion_dict * | d, |
onion_request * | req, | ||
onion_response * | res | ||
) |
Shortcut to answer some json dataIt converts to json the passed dict and returns it. The dict is freed before returning.
Shortcut for response json data. Dict is freed before return.
References HTTP_OK, onion_block_t::onion_block_data(), onion_block_t::onion_block_free(), onion_block_t::onion_block_size(), onion_dict_t::onion_dict_free(), onion_dict_t::onion_dict_to_json(), onion_response_t::onion_response_set_header(), and onion_shortcut_response_extra_headers().
int onion_use_sendfile = -1 |
Referenced by onion_shortcut_response_file().