Files | |
| file | client.h |
| file | http.c |
| file | http.h |
| file | httpclient.h |
| file | socket.c |
| file | socket.h |
Data Structures | |
| struct | _cp_client |
| struct | cp_http_status_code_entry |
| struct | _cp_http_request |
| struct | _cp_http_response |
| struct | _cp_httpsocket |
| struct | _cp_http_service |
| struct | _cp_httpclient |
| struct | _cp_url_descriptor |
| struct | _cp_httpclient_result |
| struct | _cp_httpclient_ctl |
| struct | _cp_http_transfer_descriptor |
| struct | _cp_socket |
| struct | _cp_connection_descriptor |
Defines | |
| #define | DEFAULT_CLIENT_TIMEOUT 300 |
| #define | DEFAULT_RETRIES 3 |
| #define | HTTP_PARSE_BUFSIZE 0xFFFF |
| #define | MATCHMAX 10 |
| #define | HTTP_RE_MATCHMAX 10 |
| #define | REQUEST_STAGE_START 0 |
| #define | REQUEST_STAGE_STATUS_LINE 1 |
| #define | REQUEST_STAGE_HEADERS 2 |
| #define | REQUEST_STAGE_BODY 3 |
| #define | REQUEST_STAGE_DONE 4 |
| #define | HEXDIGIT(c) |
| #define | DEFAULT_SERVER_NAME "libcprops-0.1.7" |
| #define | DEFAULT_KEEPALIVE 300 |
| #define | HTTP_KEEPALIVE DEFAULT_KEEPALIVE |
| #define | MAX_URL_LENGTH 0x400 |
| #define | DEFAULT_MAX_REDIRECTS 10 |
| #define | CPSOCKET_DEFAULT_BACKLOG 50 |
| #define | CPSOCKET_DEFAULT_DELAY_SEC 1 |
| #define | CPSOCKET_DEFAULT_DELAY_USEC 0 |
| #define | CPSOCKET_THREADPOOL_DEFAULT_SIZE_MIN 5 |
| #define | CPSOCKET_THREADPOOL_DEFAULT_SIZE_MAX 50 |
| #define | cp_connection_descriptor_get_socket(cd) ((cd)->sock) |
| #define | cp_connection_descriptor_get_addr(cd) ((cd)->addr) |
| #define | cp_connection_descriptor_get_fd(cd) ((cd)->fd) |
Typedefs | |
| typedef CPROPS_DLL struct _cp_client | cp_client |
| typedef CPROPS_DLL enum { ... } | cp_http_version |
| typedef CPROPS_DLL enum { ... } | cp_http_status_code |
| typedef CPROPS_DLL enum { ... } | connection_policy |
| typedef CPROPS_DLL enum { ... } | cp_http_content_type |
| typedef CPROPS_DLL struct _cp_http_request | cp_http_request |
| typedef CPROPS_DLL struct _cp_http_response | cp_http_response |
| typedef int(* | cp_http_service_callback )(cp_http_request *request, cp_http_response *response) |
| typedef CPROPS_DLL struct _cp_httpsocket | cp_httpsocket |
| typedef CPROPS_DLL struct _cp_http_service | cp_http_service |
| typedef CPROPS_DLL struct _cp_httpclient | cp_httpclient |
| typedef CPROPS_DLL struct _cp_url_descriptor | cp_url_descriptor |
| typedef CPROPS_DLL struct _cp_httpclient_result | cp_httpclient_result |
| typedef CPROPS_DLL struct _cp_httpclient_ctl | cp_httpclient_ctl |
| typedef void(* | cp_httpclient_callback )(cp_httpclient_result *response) |
| typedef CPROPS_DLL struct _cp_http_transfer_descriptor | cp_http_transfer_descriptor |
| typedef CPROPS_DLL enum { ... } | cp_socket_strategy |
| typedef void *(* | cp_socket_thread_function )(void *) |
| typedef int(* | cp_socket_callback )(struct _cp_socket *, int fd) |
| typedef CPROPS_DLL struct _cp_socket | cp_socket |
| typedef CPROPS_DLL struct _cp_connection_descriptor | cp_connection_descriptor |
Enumerations | |
| enum | { OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT } |
| enum | { HTTP_1_0, HTTP_1_1 } |
| enum | { HTTP_NULL_STATUS = -1, HTTP_100_CONTINUE = 100, HTTP_101_SWITCHING_PROTOCOLS = 101, HTTP_200_OK = 200, HTTP_201_CREATED = 201, HTTP_202_ACCEPTED = 202, HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203, HTTP_204_NO_CONTENT = 204, HTTP_205_RESET_CONTENT = 205, HTTP_206_PARTIAL_CONTENT = 206, HTTP_300_MULTIPLE_CHOICES = 300, HTTP_301_MOVED_PERMANENTLY = 301, HTTP_302_FOUND = 302, HTTP_303_SEE_OTHER = 303, HTTP_304_NOT_MODIFIED = 304, HTTP_305_USE_PROXY = 305, HTTP_307_TEMPORARY_REDIRECT = 307, HTTP_400_BAD_REQUEST = 400, HTTP_401_UNAUTHORIZED = 401, HTTP_402_PAYMENT_REQUIRED = 402, HTTP_403_FORBIDDEN = 403, HTTP_404_NOT_FOUND = 404, HTTP_405_METHOD_NOT_ALLOWED = 405, HTTP_406_NOT_ACCEPTABLE = 406, HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407, HTTP_408_REQUEST_TIME_OUT = 408, HTTP_409_CONFLICT = 409, HTTP_410_GONE = 410, HTTP_411_LENGTH_REQUIRED = 411, HTTP_412_PRECONDITION_FAILED = 412, HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413, HTTP_414_REQUEST_URI_TOO_LARGE = 414, HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415, HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416, HTTP_417_EXPECTATION_FAILED = 417, HTTP_500_INTERNAL_SERVER_ERROR = 500, HTTP_501_NOT_IMPLEMENTED = 501, HTTP_502_BAD_GATEWAY = 502, HTTP_503_SERVICE_UNAVAILABLE = 503, HTTP_504_GATEWAY_TIME_OUT = 504, HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505 } |
| enum | { HTTP_CONNECTION_POLICY_DEFAULT, HTTP_CONNECTION_POLICY_CLOSE, HTTP_CONNECTION_POLICY_KEEP_ALIVE } |
| enum | { TEXT, HTML, JPEG } |
| enum | cp_http_result_status { CP_HTTP_RESULT_SUCCESS, CP_HTTP_RESULT_CONNECTION_FAILED, CP_HTTP_RESULT_CONNECTION_RESET, CP_HTTP_RESULT_TIMED_OUT, CP_HTTP_RESULT_WRITE_ERROR, CP_HTTP_RESULT_READ_ERROR } |
| enum | { CPSOCKET_STRATEGY_CALLBACK, CPSOCKET_STRATEGY_THREADPOOL } |
Functions | |
| CPROPS_DLL void | cp_client_init () |
| CPROPS_DLL void | cp_client_stop_all () |
| CPROPS_DLL void | cp_client_shutdown () |
| CPROPS_DLL void | cp_tcp_add_shutdown_callback (void(*cb)(void *), void *prm) |
| CPROPS_DLL cp_client * | cp_client_create (char *host, int port) |
| CPROPS_DLL cp_client * | cp_client_create_addr (struct sockaddr_in *) |
| CPROPS_DLL void | cp_client_set_timeout (cp_client *client, int sec, int usec) |
| CPROPS_DLL void | cp_client_set_retry (cp_client *client, int retry_count) |
| CPROPS_DLL void | cp_client_set_owner (cp_client *client, void *owner) |
| CPROPS_DLL int | cp_client_connect (cp_client *client) |
| CPROPS_DLL int | cp_client_reopen (cp_client *client, char *host, int port) |
| CPROPS_DLL int | cp_client_close (cp_client *client) |
| CPROPS_DLL void | cp_client_destroy (cp_client *client) |
| CPROPS_DLL int | cp_client_read (cp_client *client, char *buf, int len) |
| CPROPS_DLL int | cp_client_read_string (cp_client *client, cp_string *str, int len) |
| CPROPS_DLL int | cp_client_write (cp_client *client, char *buf, int len) |
| CPROPS_DLL int | cp_client_write_string (cp_client *client, cp_string *str) |
| void | cp_http_signal_handler (int sig) |
| void * | session_cleanup_thread (void *) |
| int | cp_http_init () |
| void | cp_httpsocket_stop_all () |
| void | cp_httpsocket_stop (cp_httpsocket *sock) |
| void * | cp_http_add_shutdown_callback (void(*cb)(void *), void *prm) |
| void | cp_http_shutdown () |
| void | cp_http_request_delete (cp_http_request *request) |
| char * | get_http_request_type_lit (cp_http_request_type type) |
| void | urldecode (char *str, char **decoded) |
| char * | cp_http_request_get_header (cp_http_request *req, char *header) |
| char ** | cp_http_request_get_headers (cp_http_request *request) |
| char * | cp_http_request_get_parameter (cp_http_request *request, char *name) |
| void | cp_http_request_dump (cp_http_request *req) |
| cp_http_response * | cp_http_response_create (cp_http_request *req) |
| void | cp_http_response_delete (cp_http_response *response) |
| void | cp_http_response_destroy (cp_http_response *res) |
| int | cp_http_response_write (cp_connection_descriptor *cdesc, cp_http_response *res) |
| void | cp_http_response_set_status (cp_http_response *response, cp_http_status_code status) |
| cp_http_status_code | cp_http_response_get_status (cp_http_response *response) |
| void | cp_http_response_set_content_type (cp_http_response *response, cp_http_content_type type) |
| void | cp_http_response_set_content_type_string (cp_http_response *response, char *content_type) |
| char * | cp_http_response_get_content_type (cp_http_response *response) |
| void | cp_http_response_set_header (cp_http_response *response, char *name, char *value) |
| char * | cp_http_response_get_header (cp_http_response *response, char *name) |
| cp_vector * | cp_http_response_get_header_names (cp_http_response *response) |
| void | cp_http_response_set_body (cp_http_response *response, char *body) |
| void | cp_http_response_set_content (cp_http_response *response, cp_string *content) |
| cp_string * | cp_http_response_get_content (cp_http_response *response) |
| void | cp_http_response_set_connection_policy (cp_http_response *response, connection_policy policy) |
| void | cp_http_response_skip (cp_http_response *response) |
| cp_httpsocket * | cp_httpsocket_create (int port, cp_http_service_callback service) |
| void | cp_httpsocket_set_keepalive (cp_httpsocket *socket, int sec) |
| void | cp_httpsocket_set_server_name (cp_httpsocket *socket, char *name) |
| void | cp_httpsocket_set_backlog (cp_httpsocket *socket, int backlog) |
| void | cp_httpsocket_set_delay (cp_httpsocket *socket, struct timeval delay) |
| void | cp_httpsocket_set_delay_sec (cp_httpsocket *socket, long sec) |
| void | cp_httpsocket_set_delay_usec (cp_httpsocket *socket, long usec) |
| void | cp_httpsocket_set_poolsize_min (cp_httpsocket *socket, int min) |
| void | cp_httpsocket_set_poolsize_max (cp_httpsocket *socket, int max) |
| void | cp_httpsocket_delete (cp_httpsocket *sock) |
| void * | cp_httpsocket_add_shutdown_callback (cp_httpsocket *socket, void(*cb)(void *), void *prm) |
| int | cp_httpsocket_listen (cp_httpsocket *sock) |
| int | cp_httpsocket_register_service (cp_httpsocket *server, cp_http_service *service) |
| void * | cp_httpsocket_unregister_service (cp_httpsocket *server, cp_http_service *service) |
| cp_http_service * | cp_http_service_create (char *name, char *path, cp_http_service_callback callback) |
| void | cp_http_service_delete (cp_http_service *service) |
| void | cp_http_response_report_error (cp_http_response *response, cp_http_status_code code, char *message) |
| void * | cp_http_thread_fn (void *prm) |
| CPROPS_DLL cp_http_request * | cp_http_request_parse (struct _cp_httpsocket *owner, char *request, int *err) |
| CPROPS_DLL cp_vector * | cp_http_request_get_param_vector (cp_http_request *request, char *name) |
| CPROPS_DLL cp_vector * | cp_http_request_get_params (cp_http_request *request) |
| __BEGIN_DECLS CPROPS_DLL int | cp_httpclient_init () |
| CPROPS_DLL int | cp_httpclient_shutdown () |
| CPROPS_DLL cp_httpclient * | cp_httpclient_create (char *host, int port) |
| CPROPS_DLL cp_httpclient * | cp_httpclient_create_proxy (char *host, int port, char *proxy_host, int proxy_port) |
| CPROPS_DLL void | cp_httpclient_destroy (cp_httpclient *client) |
| CPROPS_DLL void | cp_httpclient_set_http_version (cp_httpclient *client, cp_http_version version) |
| CPROPS_DLL void | cp_httpclient_set_request_type (cp_httpclient *client, cp_http_request_type type) |
| CPROPS_DLL void | cp_httpclient_set_header (cp_httpclient *client, char *header, char *value) |
| CPROPS_DLL void | cp_httpclient_set_auto_drop_headers (cp_httpclient *client, short mode) |
| CPROPS_DLL void | cp_httpclient_drop_headers (cp_httpclient *client) |
| CPROPS_DLL void * | cp_httpclient_set_parameter (cp_httpclient *client, char *name, char *value) |
| CPROPS_DLL void | cp_httpclient_set_auto_drop_parameters (cp_httpclient *client, short mode) |
| CPROPS_DLL void | cp_httpclient_drop_parameters (cp_httpclient *client) |
| CPROPS_DLL void | cp_httpclient_set_user_agent (cp_httpclient *client, char *agent) |
| CPROPS_DLL void | cp_httpclient_set_timeout (cp_httpclient *client, int sec, int usec) |
| CPROPS_DLL void | cp_httpclient_set_retry (cp_httpclient *client, int retry_count) |
| CPROPS_DLL void | cp_httpclient_allow_redirects (cp_httpclient *client, int mode) |
| CPROPS_DLL void | cp_httpclient_set_max_redirects (cp_httpclient *client, int max) |
| CPROPS_DLL int | cp_httpclient_reopen (cp_httpclient *client, char *host, int port) |
| CPROPS_DLL cp_url_descriptor * | cp_url_descriptor_create (char *host, short ssl, int port, char *uri) |
| CPROPS_DLL void | cp_url_descriptor_destroy (cp_url_descriptor *desc) |
| CPROPS_DLL short | cp_url_descriptor_ssl (cp_url_descriptor *desc) |
| CPROPS_DLL char * | cp_url_descriptor_host (cp_url_descriptor *desc) |
| CPROPS_DLL int | cp_url_descriptor_port (cp_url_descriptor *desc) |
| CPROPS_DLL char * | cp_url_descriptor_uri (cp_url_descriptor *desc) |
| CPROPS_DLL cp_url_descriptor * | cp_url_descriptor_parse (char *url) |
| CPROPS_DLL cp_httpclient_result * | cp_httpclient_result_create (cp_httpclient *client) |
| CPROPS_DLL void | cp_httpclient_result_destroy (cp_httpclient_result *res) |
| CPROPS_DLL void * | cp_httpclient_result_id (cp_httpclient_result *res) |
| CPROPS_DLL cp_http_result_status | cp_httpclient_result_status (cp_httpclient_result *res) |
| CPROPS_DLL cp_http_response * | cp_httpclient_result_get_response (cp_httpclient_result *res) |
| CPROPS_DLL cp_httpclient * | cp_httpclient_result_get_client (cp_httpclient_result *res) |
| CPROPS_DLL cp_httpclient_result * | cp_httpclient_fetch (cp_httpclient *client, char *uri) |
| CPROPS_DLL cp_httpclient_ctl * | cp_httpclient_ctl_create (int background) |
| CPROPS_DLL void | cp_httpclient_ctl_destroy (cp_httpclient_ctl *ctl) |
| CPROPS_DLL fd_set * | cp_httpclient_ctl_default_get_read_fd_set (int *num) |
| CPROPS_DLL fd_set * | cp_httpclient_ctl_get_read_fd_set (cp_httpclient_ctl *ctl, int *num) |
| CPROPS_DLL fd_set * | cp_httpclient_ctl_default_get_write_fd_set (int *num) |
| CPROPS_DLL fd_set * | cp_httpclient_ctl_get_write_fd_set (cp_httpclient_ctl *ctl, int *num) |
| CPROPS_DLL cp_http_transfer_descriptor * | cp_http_transfer_descriptor_create (void *id, cp_httpclient *client, cp_httpclient_callback callback, char *uri) |
| CPROPS_DLL void | cp_http_transfer_descriptor_destroy (cp_http_transfer_descriptor *desc) |
| CPROPS_DLL int | cp_httpclient_fetch_nb (cp_httpclient *client, char *uri, void *id, cp_httpclient_callback callback, int background) |
| CPROPS_DLL int | cp_httpclient_fetch_ctl (cp_httpclient_ctl *ctl, cp_httpclient *client, char *uri, void *id, cp_httpclient_callback callback) |
| CPROPS_DLL int | cp_httpclient_fetch_nb_exec () |
| CPROPS_DLL int | cp_httpclient_fetch_ctl_exec (cp_httpclient_ctl *ctl) |
| void | cp_socket_init () |
| void | cp_socket_stop (cp_socket *sock) |
| void | cp_socket_stop_all () |
| void | cp_socket_shutdown () |
| int | setnonblocking (int sock) |
| cp_connection_descriptor * | cp_connection_descriptor_create (cp_socket *sock, struct sockaddr_in *addr, int fd) |
| void | cp_connection_descriptor_destroy (cp_connection_descriptor *conn_desc) |
| cp_socket * | cp_socket_create (int port, cp_socket_strategy strategy, void *fn) |
| void | cp_socket_set_backlog (cp_socket *socket, int backlog) |
| void | cp_socket_set_delay (cp_socket *socket, struct timeval delay) |
| void | cp_socket_set_delay_sec (cp_socket *socket, long sec) |
| void | cp_socket_set_delay_usec (cp_socket *socket, long usec) |
| void | cp_socket_set_poolsize_min (cp_socket *socket, int min) |
| void | cp_socket_set_poolsize_max (cp_socket *socket, int max) |
| void | cp_socket_set_owner (cp_socket *socket, void *owner) |
| void * | cp_socket_add_shutdown_callback (cp_socket *sock, void(*cb)(void *), void *prm) |
| void | cp_socket_delete (cp_socket *sock) |
| int | cp_socket_listen (cp_socket *sock) |
| int | cp_socket_select_callback_impl (cp_socket *sock) |
| int | cp_socket_select_threadpool_impl (cp_socket *sock) |
| int | cp_socket_select (cp_socket *sock) |
| int | cp_socket_connection_close (cp_socket *sock, int fd) |
| int | cp_connection_descrpitor_read (cp_connection_descriptor *desc, char *buf, int len) |
| int | cp_connection_descriptor_write (cp_connection_descriptor *desc, char *buf, int len) |
Variables | |
| cp_http_status_code_entry | cp_http_status_code_list [] |
| volatile int | cp_http_stopping = 0 |
| __BEGIN_DECLS typedef CPROPS_DLL enum { ... } | cp_http_request_type |
| CPROPS_DLL | _cp_httpsocket |
| volatile int | stopping_all = 0 |
|
|
return client address for given connection descriptor |
|
|
return file descriptor for given connection descriptor Definition at line 256 of file socket.h. Referenced by cp_http_response_write(). |
|
|
return cp_socket struct for given connection descriptor Definition at line 252 of file socket.h. Referenced by cp_http_response_write(). |
|
|
seconds to wait for responses |
|
|
default connect retries |
|
|
Value: ((c) >= '0' && (c) <= '9' ? (c) - '0' : \ ((c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 0xA : \ ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 0xA : -1))) |
|
|
connection handling policy. HTTP_CONNECTION_POLICY_DEFAULT defaults to HTTP_CONNECTION_POLICY_CLOSE for HTTP/1.0 and to HTTP_CONNECTION_POLICY_KEEP_ALIVE for HTTP/1.1. |
|
|
cp_client is a 'client socket'. create a cp_client with address information, call cp_client_connect() and communicate on the resulting file descriptor. Referenced by cp_client_create(), and cp_client_create_addr(). |
|
|
connection descriptor structure Referenced by cp_connection_descriptor_create(). |
|
|
http request descriptor |
|
|
http response holder Referenced by cp_http_response_create(), cp_httpclient_fetch(), and cp_httpclient_result_get_response(). |
|
|
http service descriptor Referenced by cp_http_service_create(). |
|
|
service function prototype |
|
|
HTTP status codes Referenced by cp_http_response_get_status(). |
|
|
transfer descriptor for async interface Referenced by cp_httpclient_ctl_create(), and cp_httpclient_fetch_ctl(). |
|
|
HTTP versions |
|
|
http client socket wrapper Referenced by cp_httpclient_create(), cp_httpclient_create_proxy(), and cp_httpclient_result_get_client(). |
|
|
asynchronous interface control block. By default asynchronous transfers use a static block shared between all client transfers. To separate transfers into different groups, create a cp_httpclient_ctl control block and use _fetch_ctl_nb and _fetch_ctl_nb_exec(). Referenced by cp_httpclient_ctl_create(). |
|
|
wrapper for asynchronous interface callback Referenced by cp_httpclient_fetch(), and cp_httpclient_result_create(). |
|
|
http server socket Referenced by cp_httpsocket_create(). |
|
|
cp_socket is a 'server socket'. create a cp_socket to listen on a port, specify a callback to implemet your communication protocol (libcprops provides a basic http implementation you could plug in) and the strategy you want for handling handling multiple connections - use a thread pool to serve each connection on its own thread or a more select()-like approach. If you create a socket with the CPSOCKET_STRATEGY_THREADPOOL, supply a thread function to handle communication once a connection has been accept()-ed. Your cp_thread function should close the connection when done and check the 'closing' flag, which is set to 1 on shutdown. If you create a socket with the CPSOCKET_STRATEGY_CALLBACK, supply a callback to process incremental feeds as they come along. Referenced by cp_http_response_write(), cp_httpsocket_create(), cp_socket_create(), and cp_socket_stop_all(). |
|
|
function prototype for callback implementation |
|
|
cp_socket connection handling strategy |
|
|
thread function for threadpool implementation |
|
|
wrapper for url information Referenced by cp_httpclient_fetch(). |
|
|
HTTP request types |
|
|
HTTP versions |
|
|
HTTP status codes |
|
|
connection handling policy. HTTP_CONNECTION_POLICY_DEFAULT defaults to HTTP_CONNECTION_POLICY_CLOSE for HTTP/1.0 and to HTTP_CONNECTION_POLICY_KEEP_ALIVE for HTTP/1.1. |
|
|
cp_socket connection handling strategy |
|
|
result codes for HTTP requests Definition at line 262 of file httpclient.h. Referenced by cp_httpclient_result_status(). |
|
|
close a client connection Definition at line 668 of file client.c. References cp_perror(). Referenced by cp_client_reopen(), and cp_httpclient_destroy(). |
|
|
open connection Definition at line 572 of file client.c. References _cp_client::addr, cp_error(), _cp_client::hostspec, and _cp_client::retry. Referenced by cp_client_reopen(). |
|
||||||||||||
|
create a client socket Definition at line 396 of file client.c. References cp_client, cp_client_destroy(), cp_perror(), _cp_client::host, _cp_client::port, and _cp_client::retry. Referenced by cp_httpclient_create(), and cp_httpclient_create_proxy(). |
|
|
create a client socket with a struct sockaddr * Definition at line 496 of file client.c. References _cp_client::addr, cp_client, and _cp_client::retry. |
|
|
deallocate a cp_client Definition at line 707 of file client.c. Referenced by cp_client_create(), and cp_httpclient_destroy(). |
|
|
recommended to call before using tcp client socket functions Definition at line 255 of file client.c. References cp_fatal(), and cp_socket_init(). Referenced by cp_httpclient_init(). |
|
||||||||||||||||
|
use the same wrapper for a different address. this will close an existing connection, change the host and port settings on the wrapper and attempt to connect. maybe rename this function. Definition at line 450 of file client.c. References _cp_client::addr, cp_client_close(), cp_client_connect(), cp_error(), cp_perror(), _cp_client::host, _cp_client::hostspec, and _cp_client::port. Referenced by cp_httpclient_fetch(), and cp_httpclient_reopen(). |
|
||||||||||||
|
useful free pointer for client code Definition at line 527 of file client.c. References _cp_client::owner. |
|
||||||||||||
|
number of connection retries Definition at line 521 of file client.c. References _cp_client::retry. Referenced by cp_httpclient_set_retry(). |
|
||||||||||||||||
|
set the timeout - (0, 0) for no timeout Definition at line 514 of file client.c. References _cp_client::timeout. Referenced by cp_httpclient_set_timeout(). |
|
|
performs cleanup Definition at line 271 of file client.c. References cp_socket_shutdown(). Referenced by cp_httpclient_shutdown(). |
|
|
call from signal handler to stop sockets in waiting select() and close all connections |
|
||||||||||||||||
|
internal: create a new connection descriptor Definition at line 391 of file socket.c. References _cp_connection_descriptor::addr, cp_connection_descriptor, cp_error(), and _cp_connection_descriptor::sock. |
|
|
deallocate a connection descriptor Definition at line 428 of file socket.c. References cp_socket_connection_close(). |
|
||||||||||||||||
|
write on a connection descriptor Definition at line 1118 of file socket.c. References _cp_connection_descriptor::bytes_sent, and cp_error(). |
|
||||||||||||||||
|
read from a connection descriptor Definition at line 1093 of file socket.c. References _cp_connection_descriptor::bytes_read, and cp_error(). |
|
||||||||||||
|
called when shutting down http layer Definition at line 278 of file http.c. References cp_wrap. |
|
|
recommended to call before using cp_httpsocket api Definition at line 198 of file http.c. References COLLECTION_MODE_DEEP, cp_hash_compare_int(), cp_hash_int(), cp_hashlist_create_by_mode(), cp_hashtable_create(), cp_hashtable_put(), and cp_socket_init(). Referenced by cp_httpsocket_create(). |
|
|
deallocate an http request descriptor Definition at line 679 of file http.c. References cp_hashtable_destroy(). |
|
|
dump a cp_http_request descriptor (uses cp_info) Definition at line 1017 of file http.c. References cp_hashtable_count(), cp_hashtable_get(), and cp_hashtable_get_keys(). |
|
||||||||||||
|
return value of specified header or NULL if none Definition at line 977 of file http.c. References cp_hashtable_get(). |
|
|
return a newly allocated array of header names Definition at line 987 of file http.c. References cp_hashtable_get_keys(). |
|
||||||||||||
|
return vector of GET or POST parameters with specified name |
|
||||||||||||
|
return a single parameter with the specified name Definition at line 996 of file http.c. References cp_hashtable_get(). |
|
|
return all GET or POST parameters for given request |
|
||||||||||||||||
|
parse an http request |
|
|
(internal) create a new response descriptor Definition at line 1082 of file http.c. References COLLECTION_MODE_COPY, COLLECTION_MODE_DEEP, COLLECTION_MODE_NOSYNC, cp_copy_fn, cp_hash_compare_string(), cp_hash_string(), cp_hashtable_create_by_option(), cp_http_response, _cp_http_response::header, _cp_http_response::request, _cp_http_response::servername, _cp_http_response::status, and _cp_http_response::version. |
|
|
(internal) deallocate a response descriptor Definition at line 1111 of file http.c. References cp_hashtable_destroy(), and cp_string_delete(). Referenced by cp_http_response_destroy(), cp_httpclient_fetch(), cp_httpclient_result_destroy(), and cp_httpsocket_delete(). |
|
|
deallocate a response descriptor Definition at line 1134 of file http.c. References cp_http_response_delete(). |
|
|
get the content of an http response Definition at line 1360 of file http.c. References cp_string. |
|
|
get the Content-Type header value for an http response Definition at line 1319 of file http.c. References cp_hashtable_get(). |
|
||||||||||||
|
retrieve header content for one header Definition at line 1330 of file http.c. References cp_hashtable_get(). |
|
|
returns a vector containing header names Definition at line 1335 of file http.c. References cp_hashtable_count(), and cp_hashtable_get_keys(). |
|
|
get the status code of an http response Definition at line 1302 of file http.c. References cp_http_status_code. |
|
||||||||||||||||
|
set up a response reporting an error Definition at line 1733 of file http.c. References cp_hashtable_get(), cp_http_response_set_body(), cp_http_response_set_content_type(), and cp_http_response_set_status(). |
|
||||||||||||
|
deprecated - use cp_http_response_set_content instead Definition at line 1348 of file http.c. Referenced by cp_http_response_report_error(). |
|
||||||||||||
|
set the Connection header on a cp_http_response descriptor |
|
||||||||||||
|
set the (possibly binary) content on an http response |
|
||||||||||||
|
deprecated - use cp_http_response_set_content_type_string Definition at line 1307 of file http.c. Referenced by cp_http_response_report_error(). |
|
||||||||||||
|
set the Content-Type header on an http response |
|
||||||||||||||||
|
set an arbitrary header on an http response Definition at line 1324 of file http.c. References cp_hashtable_put(). |
|
||||||||||||
|
set the status code on an http response Definition at line 1296 of file http.c. Referenced by cp_http_response_report_error(). |
|
|
sets the 'skip' flag on an http response, which prevents the response being deserialized and written to the client by the http framework. this is needed if the service function writes directly to the underlying socket. |
|
||||||||||||
|
(internal) output an http response on given connection Definition at line 1139 of file http.c. References cp_connection_descriptor_get_fd, cp_connection_descriptor_get_socket, cp_hashtable_count(), cp_hashtable_get(), cp_hashtable_get_keys(), cp_log(), cp_ndump(), cp_nlog(), cp_socket, and LOG_LEVEL_INFO. |
|
||||||||||||||||
|
create a new cp_http_service descriptor. client requests for uris beginning with 'path' will be delegated to this service once registered on a listening socket. Definition at line 1669 of file http.c. References cp_error(), cp_http_service, _cp_http_service::name, _cp_http_service::path, and _cp_http_service::service. |
|
|
deallocate a cp_http_service descriptor Definition at line 1689 of file http.c. References cp_warn(). Referenced by cp_httpsocket_register_service(). |
|
|
call to perform cleanup after using cp_httpsocket api Definition at line 292 of file http.c. References cp_destructor_fn, cp_hashlist_destroy_custom(), cp_hashtable_destroy(), and cp_socket_shutdown(). |
|
||||||||||||
|
set client behavior on HTTP 302, 302 etc. responses Definition at line 542 of file httpclient.c. References _cp_httpclient::follow_redirects. |
|
||||||||||||
|
create an http client wrapper to communicate with the given host on the given port Definition at line 394 of file httpclient.c. References cp_client_create(), cp_httpclient, cp_httpclient_destroy(), and _cp_httpclient::socket. |
|
||||||||||||||||||||
|
create an http client wrapper to communicate with the given host on the given port using the given proxy settings Definition at line 410 of file httpclient.c. References cp_client_create(), cp_httpclient, cp_httpclient_destroy(), _cp_httpclient::proxy_host, _cp_httpclient::proxy_port, and _cp_httpclient::socket. |
|
|
create an asynchronous client transfer block for separate transfers. if background is 0, transfers must be driven by calling cp_httpclient_fetch_ctl_exec(). If background is 1, transfers will be run on a separate thread. If background is greater than 1, a thread pool is created to perform background transfers and the given value is used as the maximal size of the thread pool. Definition at line 2139 of file httpclient.c. References cp_hash_addr(), cp_hash_compare_addr(), cp_hashlist_create, cp_http_transfer_descriptor, cp_httpclient_ctl, cp_httpclient_ctl_destroy(), cp_thread_pool_create(), _cp_httpclient_ctl::desc, _cp_httpclient_ctl::pool, _cp_httpclient_ctl::running, _cp_httpclient_ctl::size, and _cp_httpclient_ctl::stack. Referenced by cp_httpclient_init(). |
|
|
retrieve a read file descriptor set for select() for the default transfer control block. If num is non-null it is set to the number of entries in the file descriptor array. Definition at line 2224 of file httpclient.c. References cp_httpclient_ctl_get_read_fd_set(). |
|
|
retrieve a write file descriptor set for select() for the default transfer control block. If num is non-null it is set to the number of entries in the file descriptor array. Definition at line 2236 of file httpclient.c. References cp_httpclient_ctl_get_write_fd_set(). |
|
|
transfer blocks created with cp_httpclient_ctl_create() are not released by the framework and must be finalized by calling cp_httpclient_ctl_destroy(). Definition at line 2179 of file httpclient.c. References cp_destructor_fn, cp_hashlist_destroy_custom(), cp_thread_pool_destroy(), cp_thread_pool_stop(), and _cp_httpclient_ctl::running. Referenced by cp_httpclient_ctl_create(), and cp_httpclient_shutdown(). |
|
||||||||||||
|
retrieve a read file descriptor set prepared for select(). If num is non- null it is set to the number of entries in the file descriptor array. Definition at line 2229 of file httpclient.c. References _cp_httpclient_ctl::fdmax, and _cp_httpclient_ctl::ufds_r. Referenced by cp_httpclient_ctl_default_get_read_fd_set(). |
|
||||||||||||
|
retrieve a write file descriptor set prepared for select(). If num is non- null it is set to the number of entries in the file descriptor array. Definition at line 2241 of file httpclient.c. References _cp_httpclient_ctl::fdmax, and _cp_httpclient_ctl::ufds_w. Referenced by cp_httpclient_ctl_default_get_write_fd_set(). |
|
|
deallocate a cp_httpclient wrapper. Definition at line 478 of file httpclient.c. References cp_client_close(), cp_client_destroy(), and cp_hashtable_destroy(). Referenced by cp_httpclient_create(), and cp_httpclient_create_proxy(). |
|
|
deallocate cgi parameters Definition at line 516 of file httpclient.c. References cp_hashtable_remove_all(). Referenced by cp_httpclient_fetch(). |
|
|
deallocate cgi parameters Definition at line 614 of file httpclient.c. References cp_hashtable_remove_all(). Referenced by cp_httpclient_fetch(). |
|
||||||||||||
|
read uri content - synchronous interface Definition at line 1392 of file httpclient.c. References cp_client_reopen(), cp_hashtable_get(), cp_http_response, cp_http_response_delete(), cp_httpclient_drop_headers(), cp_httpclient_drop_parameters(), cp_httpclient_result, cp_httpclient_result_create(), cp_string, cp_string_destroy(), and cp_url_descriptor. |
|
||||||||||||||||||||||||
|
same as cp_httpclient_fetch_nb but allows specifying a different asynchronous transfer control block. Definition at line 2314 of file httpclient.c. References _cp_http_transfer_descriptor::buf, cp_hashlist_append(), cp_http_transfer_descriptor, and _cp_http_transfer_descriptor::remaining. Referenced by cp_httpclient_fetch_nb(). |
|
|
same as cp_httpclient_fetch_nb_exec() but allows specifying a different aysnchronous transfer control block. Definition at line 2101 of file httpclient.c. References cp_error(), and cp_hashlist_item_count(). Referenced by cp_httpclient_fetch_nb_exec(). |
|
||||||||||||||||||||||||
|
perform an asynchronous fetch. If background is non-zero, the fetch happens in a separate thread and the callback is invoked asynchronously. Otherwise the caller must make repeated calls to cp_httpclient_fetch_nb_exec() until all transfers complete. cp_httpclient_fetch_nb_next() returns the number of active transfers. cp_httpclient_fetch_nb returns zero if the request could be registered, non-zero otherwise. Definition at line 2304 of file httpclient.c. References cp_httpclient_fetch_ctl(). |
|
|
non-blocking fetches executing in the foreground must be driven by calls to cp_httpclient_fetch_nb_exec(). The callback for each request is made once it completes or if an error occurs. cp_httplcient_fetch_nb_exec() returns the number of active requests. Zero indicates all transfers have completed. Definition at line 2096 of file httpclient.c. References cp_httpclient_fetch_ctl_exec(). |
|
|
api initialization function Definition at line 91 of file httpclient.c. References COLLECTION_MODE_DEEP, cp_client_init(), cp_destructor_fn, cp_error(), cp_httpclient_ctl_create(), cp_trie_create_trie(), and cp_trie_destroy(). |
|
||||||||||||||||
|
use the same wrapper for a different address. this will close an existing connection, change the host and port settings on the wrapper and attempt to connect. maybe rename this function. Definition at line 1507 of file httpclient.c. References cp_client_reopen(). |
|
|
(internal) create a cp_httpclient_result object Definition at line 1548 of file httpclient.c. References _cp_httpclient_result::client, and cp_httpclient_result. Referenced by cp_httpclient_fetch(). |
|
|
destructor for cp_httpclient_result objects Definition at line 1575 of file httpclient.c. References cp_http_response_delete(). |
|
|
get the client object the response was made on Definition at line 1599 of file httpclient.c. References cp_httpclient. |
|
|
get the response object from a result descriptor Definition at line 1594 of file httpclient.c. References cp_http_response. |
|
|
get the client assigned id from a result descriptor Definition at line 1584 of file httpclient.c. References _cp_httpclient_result::id. |
|
|
get the result status code from a result descriptor Definition at line 1589 of file httpclient.c. References cp_http_result_status, and _cp_httpclient_result::result. |
|
||||||||||||
|
determine whether headers are automatically deleted or not - disabled by default Definition at line 521 of file httpclient.c. References _cp_httpclient::auto_drop_headers. |
|
||||||||||||
|
determine whether cgi parameters are automatically deleted or not - enabled by default Definition at line 619 of file httpclient.c. |
|
||||||||||||||||
|
set an arbitrary header. Any existing value is overriden. Definition at line 508 of file httpclient.c. References cp_hashtable_put(), and cp_hashtable_remove(). |
|
||||||||||||
|
set the HTTP version for subsequent requests Definition at line 496 of file httpclient.c. References _cp_httpclient::version. |
|
||||||||||||
|
maximal number of server redirect directives to follow - default is 10 Definition at line 547 of file httpclient.c. References _cp_httpclient::max_redirects. |
|
||||||||||||||||
|
set a cgi parameter Definition at line 587 of file httpclient.c. References COLLECTION_MODE_COPY, COLLECTION_MODE_DEEP, COLLECTION_MODE_NOSYNC, cp_copy_fn, cp_hash_compare_string(), cp_hash_string(), cp_hashtable_create_by_option(), cp_hashtable_put(), and cp_hashtable_remove(). |
|
||||||||||||
|
set the request type for subsequent requests. GET by default. Definition at line 502 of file httpclient.c. References _cp_httpclient::type. |
|
||||||||||||
|
set the number of times to retry a connection on failure Definition at line 537 of file httpclient.c. References cp_client_set_retry(). |
|
||||||||||||||||
|
set the timeout value for the underlying tcp socket Definition at line 531 of file httpclient.c. References cp_client_set_timeout(). |
|
||||||||||||
|
set a value for the 'User-Agent' header. Default is libcprops-(version) Definition at line 526 of file httpclient.c. References cp_hashtable_put(). |
|
|
api cleanup function Definition at line 152 of file httpclient.c. References cp_client_shutdown(), cp_httpclient_ctl_destroy(), cp_socket_shutdown(), and cp_trie_destroy(). |
|
||||||||||||||||
|
called when closing a socket Definition at line 1613 of file http.c. References cp_socket_add_shutdown_callback(). |
|
||||||||||||
|
create a cp_http_socket with the specified default cp_http_service Definition at line 1486 of file http.c. References cp_error(), cp_hashlist_append(), cp_http_init(), cp_httpsocket, cp_httpsocket_set_keepalive(), cp_socket, cp_socket_create(), cp_socket_delete(), cp_socket_set_owner(), _cp_httpsocket::default_service, _cp_httpsocket::id, and _cp_httpsocket::sock. |
|
|
deallocate a cp_httpsocket structure Definition at line 1590 of file http.c. References cp_destructor_fn, cp_hashlist_destroy_custom(), cp_hashlist_destroy_deep(), cp_hashlist_remove(), cp_http_response_delete(), cp_socket_delete(), and cp_trie_destroy(). |
|
|
puts socket in listening mode Definition at line 1620 of file http.c. References cp_socket_listen(), and cp_socket_select(). |
|
||||||||||||
|
register a service on a socket Definition at line 1630 of file http.c. References COLLECTION_MODE_DEEP, cp_destructor_fn, cp_http_service_delete(), cp_trie_add(), cp_trie_create_trie(), and _cp_httpsocket::service. |
|
||||||||||||
|
set maximal number of queued requests before accept() starts refusing connections Definition at line 1560 of file http.c. References cp_socket_set_backlog(). |
|
||||||||||||
|
set time to block in accept Definition at line 1565 of file http.c. References cp_socket_set_delay(). |
|
||||||||||||
|
set micro sec. to block in accept() Definition at line 1575 of file http.c. References cp_socket_set_delay_usec(). |
|
||||||||||||
|
set value for Keep-Alive header Definition at line 1550 of file http.c. References _cp_httpsocket::keepalive. Referenced by cp_httpsocket_create(). |
|
||||||||||||
|
set upper limit on thread pool size Definition at line 1585 of file http.c. References cp_socket_set_poolsize_max(). |
|
||||||||||||
|
set lower limit on thread pool size Definition at line 1580 of file http.c. References cp_socket_set_poolsize_min(). |
|
||||||||||||
|
set value for Server header Definition at line 1555 of file http.c. References _cp_httpsocket::server_name. |
|
||||||||||||
|
unregister a service on a socket Definition at line 1649 of file http.c. References cp_trie_remove(). |
|
||||||||||||||||
|
add a callback to be made on socket shutdown Definition at line 552 of file socket.c. References cp_destructor_fn, and cp_wrap. Referenced by cp_httpsocket_add_shutdown_callback(). |
|
||||||||||||
|
close a (non ssl) connection Definition at line 1065 of file socket.c. References cp_hashlist_get(), and cp_perror(). Referenced by cp_connection_descriptor_destroy(), and cp_socket_delete(). |
|
||||||||||||||||
|
create a new cp_socket struct Definition at line 443 of file socket.c. References _cp_socket::action, _cp_socket::backlog, _cp_socket::callback, COLLECTION_MODE_DEEP, cp_error(), cp_hash_compare_int(), cp_hash_int(), cp_hashlist_append(), cp_hashlist_create_by_option(), cp_socket, cp_socket_init(), _cp_socket::delay, _cp_socket::fds, _cp_socket::id, _cp_socket::poolsize_max, _cp_socket::poolsize_min, _cp_socket::port, _cp_socket::strategy, and _cp_socket::thread_fn. Referenced by cp_httpsocket_create(). |
|
|
deallocate a socket descriptor Definition at line 564 of file socket.c. References COLLECTION_LOCK_NONE, cp_destructor_fn, cp_hashlist_create_iterator(), cp_hashlist_destroy_custom(), cp_hashlist_entry_get_key(), cp_hashlist_iterator, cp_hashlist_iterator_destroy(), cp_hashlist_iterator_next(), cp_hashlist_remove(), cp_socket_connection_close(), cp_thread_pool_destroy(), and cp_thread_pool_stop(). Referenced by cp_httpsocket_create(), and cp_httpsocket_delete(). |
|
|
recommended to call before using socket functions Definition at line 198 of file socket.c. References COLLECTION_MODE_DEEP, cp_hash_compare_int(), cp_hash_int(), and cp_hashlist_create_by_mode(). Referenced by cp_client_init(), cp_http_init(), and cp_socket_create(). |
|
|
cp_socket_listen attempts to create a SOCK_STREAM socket with socket(), bind to a local port with bind(), and set the socket to listen for connections with listen(). Definition at line 616 of file socket.c. References cp_perror(), and cp_thread_pool_create(). Referenced by cp_httpsocket_listen(). |
|
|
block and wait for connections Definition at line 997 of file socket.c. Referenced by cp_httpsocket_listen(). |
|
||||||||||||
|
set number of outstanding requests before accept() fails new connections Definition at line 517 of file socket.c. References _cp_socket::backlog. Referenced by cp_httpsocket_set_backlog(). |
|
||||||||||||
|
delay time before re-accept()ing Definition at line 522 of file socket.c. References _cp_socket::delay. Referenced by cp_httpsocket_set_delay(). |
|
||||||||||||
|
seconds before re-accept()ing Definition at line 527 of file socket.c. References _cp_socket::delay. |
|
||||||||||||
|
microseconds before re-accept()ing Definition at line 532 of file socket.c. References _cp_socket::delay. Referenced by cp_httpsocket_set_delay_usec(). |
|
||||||||||||
|
useful free pointer for client code Definition at line 547 of file socket.c. References _cp_socket::owner. Referenced by cp_httpsocket_create(). |
|
||||||||||||
|
upper size limit for threadpool implementation Definition at line 542 of file socket.c. References _cp_socket::poolsize_max. Referenced by cp_httpsocket_set_poolsize_max(). |
|
||||||||||||
|
lower size limit for threadpool implementation Definition at line 537 of file socket.c. References _cp_socket::poolsize_min. Referenced by cp_httpsocket_set_poolsize_min(). |
|
|
performs cleanup Definition at line 287 of file socket.c. References cp_destructor_fn, cp_hashlist_destroy(), and cp_socket_stop_all(). Referenced by cp_client_shutdown(), cp_http_shutdown(), and cp_httpclient_shutdown(). |
|
|
call from signal handler to stop sockets in waiting select() and close all connections Definition at line 271 of file socket.c. References COLLECTION_LOCK_READ, cp_hashlist_iterator, cp_hashlist_iterator_next_value(), cp_hashlist_iterator_release(), and cp_socket. Referenced by cp_socket_shutdown(). |
|
||||||||||||
|
add callback to be made on tcp layer shutdown Definition at line 257 of file socket.c. References cp_wrap. |
|
|
HTTP request types |
1.3.9.1