serf.h (0.1.2) | | serf.h (0.2.0) |
| | |
skipping to change at line 30 ¶ | | skipping to change at line 30 ¶ |
* @file serf.h | | * @file serf.h |
* @brief Main serf header file | | * @brief Main serf header file |
*/ | | */ |
| | |
#include <apr.h> | | #include <apr.h> |
#include <apr_errno.h> | | #include <apr_errno.h> |
#include <apr_allocator.h> | | #include <apr_allocator.h> |
#include <apr_pools.h> | | #include <apr_pools.h> |
#include <apr_network_io.h> | | #include <apr_network_io.h> |
#include <apr_time.h> | | #include <apr_time.h> |
| | #include <apr_poll.h> |
| | #include <apr_uri.h> |
| | |
#include "serf_declare.h" | | #include "serf_declare.h" |
| | |
#ifdef __cplusplus | | #ifdef __cplusplus |
extern "C" { | | extern "C" { |
#endif | | #endif |
| | |
/* Forward declare some structures */ | | /* Forward declare some structures */ |
typedef struct serf_context_t serf_context_t; | | typedef struct serf_context_t serf_context_t; |
| | |
| | |
skipping to change at line 79 ¶ | | skipping to change at line 81 ¶ |
/** | | /** |
* Create a new context for serf operations. | | * Create a new context for serf operations. |
* | | * |
* A serf context defines a control loop which processes multiple | | * A serf context defines a control loop which processes multiple |
* connections simultaneously. | | * connections simultaneously. |
* | | * |
* The context will be allocated within @a pool. | | * The context will be allocated within @a pool. |
*/ | | */ |
SERF_DECLARE(serf_context_t *) serf_context_create(apr_pool_t *pool); | | SERF_DECLARE(serf_context_t *) serf_context_create(apr_pool_t *pool); |
| | |
| | /** |
| | * Callback function. Add a socket to the externally managed poll set. |
| | * |
| | * Both @a pfd and @a serf_baton should be used when calling serf_event_tri |
| | gger |
| | * later. |
| | */ |
| | typedef apr_status_t (*serf_socket_add_t)(void *user_baton, |
| | apr_pollfd_t *pfd, |
| | void *serf_baton); |
| | /** |
| | * Callback function. Remove the socket, identified by both @a pfd and |
| | * @a serf_baton from the externally managed poll set. |
| | */ |
| | typedef apr_status_t (*serf_socket_remove_t)(void *user_baton, |
| | apr_pollfd_t *pfd, |
| | void *serf_baton); |
| | |
| | /* Create a new context for serf operations. |
| | * |
| | * Use this function to make serf not use its internal control loop, but |
| | * instead rely on an external event loop. Serf will use the @a addf and @a |
| | rmf |
| | * callbacks to notify of any event on a connection. The @a user_baton will |
| | be |
| | * passed through the addf and rmf callbacks. |
| | * |
| | * The context will be allocated within @a pool. |
| | */ |
| | SERF_DECLARE(serf_context_t *) serf_context_create_ex(void *user_baton, |
| | serf_socket_add_t add |
| | f, |
| | serf_socket_remove_t |
| | rmf, |
| | apr_pool_t *pool); |
| | |
| | /** |
| | * Make serf process events on a connection, identified by both @a pfd and |
| | * @a serf_baton. |
| | * |
| | * Any outbound data is delivered, and incoming data is made available to |
| | * the associated response handlers and their buckets. |
| | * |
| | * If any data is processed (incoming or outgoing), then this function will |
| | * return with APR_SUCCESS. |
| | */ |
| | SERF_DECLARE(apr_status_t) serf_event_trigger(serf_context_t *s, |
| | void *serf_baton, |
| | const apr_pollfd_t *pfd); |
| | |
/** @see serf_context_run should not block at all. */ | | /** @see serf_context_run should not block at all. */ |
#define SERF_DURATION_NOBLOCK 0 | | #define SERF_DURATION_NOBLOCK 0 |
/** @see serf_context_run should run for (nearly) "forever". */ | | /** @see serf_context_run should run for (nearly) "forever". */ |
#define SERF_DURATION_FOREVER 2000000000 /* approx 1^31 */ | | #define SERF_DURATION_FOREVER 2000000000 /* approx 1^31 */ |
| | |
/** | | /** |
* Run the main networking control loop. | | * Run the main networking control loop. |
* | | * |
* The set of connections defined by the serf context @a ctx are processed. | | * The set of connections defined by the serf context @a ctx are processed. |
* Any outbound data is delivered, and incoming data is made available to | | * Any outbound data is delivered, and incoming data is made available to |
| | |
skipping to change at line 105 ¶ | | skipping to change at line 152 ¶ |
* | | * |
* If no activity occurs within the specified timeout duration, then | | * If no activity occurs within the specified timeout duration, then |
* APR_TIMEUP is returned. | | * APR_TIMEUP is returned. |
* | | * |
* All temporary allocations will be made in @a pool. | | * All temporary allocations will be made in @a pool. |
*/ | | */ |
SERF_DECLARE(apr_status_t) serf_context_run(serf_context_t *ctx, | | SERF_DECLARE(apr_status_t) serf_context_run(serf_context_t *ctx, |
apr_short_interval_time_t durat
ion, | | apr_short_interval_time_t durat
ion, |
apr_pool_t *pool); | | apr_pool_t *pool); |
| | |
| | SERF_DECLARE(apr_status_t) serf_context_prerun(serf_context_t *ctx); |
| | |
| | /** |
| | * Callback function for progress information. @a progress indicates cumula |
| | tive |
| | * number of bytes read or written, for the whole context. |
| | */ |
| | typedef void (*serf_progress_t)(void *progress_baton, |
| | apr_off_t read, |
| | apr_off_t write); |
| | |
| | /** |
| | * Sets the progress callback function. @a progress_func will be called eve |
| | ry |
| | * time bytes are read of or written on a socket. |
| | */ |
| | SERF_DECLARE(void) serf_context_set_progress_cb( |
| | serf_context_t *ctx, |
| | const serf_progress_t progress_func, |
| | void *progress_baton); |
| | |
/** @} */ | | /** @} */ |
| | |
/** | | /** |
* @defgroup serf connections and requests | | * @defgroup serf connections and requests |
* @ingroup serf | | * @ingroup serf |
* @{ | | * @{ |
*/ | | */ |
| | |
/** | | /** |
* When a connection is established, the application needs to wrap some | | * When a connection is established, the application needs to wrap some |
| | |
skipping to change at line 256 ¶ | | skipping to change at line 322 ¶ |
SERF_DECLARE(serf_connection_t *) serf_connection_create( | | SERF_DECLARE(serf_connection_t *) serf_connection_create( |
serf_context_t *ctx, | | serf_context_t *ctx, |
apr_sockaddr_t *address, | | apr_sockaddr_t *address, |
serf_connection_setup_t setup, | | serf_connection_setup_t setup, |
void *setup_baton, | | void *setup_baton, |
serf_connection_closed_t closed, | | serf_connection_closed_t closed, |
void *closed_baton, | | void *closed_baton, |
apr_pool_t *pool); | | apr_pool_t *pool); |
| | |
/** | | /** |
| | * Create a new connection associated with the @a ctx serf context. |
| | * |
| | * A connection will be created to (eventually) connect to the address |
| | * specified by @a address. The address must live at least as long as |
| | * @a pool (thus, as long as the connection object). |
| | * |
| | * The host address will be looked up based on the hostname in @a host_info |
| | . |
| | * |
| | * The connection object will be allocated within @a pool. Clearing or |
| | * destroying this pool will close the connection, and terminate any |
| | * outstanding requests or responses. |
| | * |
| | * When the connection is closed (upon request or because of an error), |
| | * then the @a closed callback is invoked, and @a closed_baton is passed. |
| | * |
| | * ### doc on setup(_baton). tweak below comment re: acceptor. |
| | * NULL may be passed for @a acceptor and @a closed; default implementation |
| | s |
| | * will be used. |
| | * |
| | * Note: the connection is not made immediately. It will be opened on |
| | * the next call to @see serf_context_run. |
| | */ |
| | SERF_DECLARE(apr_status_t) serf_connection_create2( |
| | serf_connection_t **conn, |
| | serf_context_t *ctx, |
| | apr_uri_t host_info, |
| | serf_connection_setup_t setup, |
| | void *setup_baton, |
| | serf_connection_closed_t closed, |
| | void *closed_baton, |
| | apr_pool_t *pool); |
| | |
| | /** |
* Reset the connection, but re-open the socket again. | | * Reset the connection, but re-open the socket again. |
*/ | | */ |
SERF_DECLARE(apr_status_t) serf_connection_reset( | | SERF_DECLARE(apr_status_t) serf_connection_reset( |
serf_connection_t *conn); | | serf_connection_t *conn); |
| | |
/** | | /** |
* Close the connection associated with @a conn and cancel all pending requ
ests. | | * Close the connection associated with @a conn and cancel all pending requ
ests. |
* | | * |
* The closed callback passed to serf_connection_create() will be invoked | | * The closed callback passed to serf_connection_create() will be invoked |
* with APR_SUCCESS. | | * with APR_SUCCESS. |
*/ | | */ |
SERF_DECLARE(apr_status_t) serf_connection_close( | | SERF_DECLARE(apr_status_t) serf_connection_close( |
serf_connection_t *conn); | | serf_connection_t *conn); |
| | |
/** | | /** |
| | * Sets the maximum number of outstanding requests @a max_requests on the |
| | * connection @a conn. Setting max_requests to 0 means unlimited (the defau |
| | lt). |
| | * Ex.: setting max_requests to 1 means a request is sent when a response o |
| | n the |
| | * previous request was received and handled. |
| | */ |
| | SERF_DECLARE(void) |
| | serf_connection_set_max_outstanding_requests(serf_connection_t *conn, |
| | unsigned int max_requests); |
| | |
| | /** |
* Setup the @a request for delivery on its connection. | | * Setup the @a request for delivery on its connection. |
* | | * |
* Right before this is invoked, @a pool will be built within the | | * Right before this is invoked, @a pool will be built within the |
* connection's pool for the request to use. The associated response will | | * connection's pool for the request to use. The associated response will |
* be allocated within that subpool. An associated bucket allocator will | | * be allocated within that subpool. An associated bucket allocator will |
* be built. These items may be fetched from the request object through | | * be built. These items may be fetched from the request object through |
* @see serf_request_get_pool or @see serf_request_get_alloc. | | * @see serf_request_get_pool or @see serf_request_get_alloc. |
* | | * |
* The content of the request is specified by the @a req_bkt bucket. When | | * The content of the request is specified by the @a req_bkt bucket. When |
* a response arrives, the @a acceptor callback will be invoked (along with | | * a response arrives, the @a acceptor callback will be invoked (along with |
| | |
skipping to change at line 315 ¶ | | skipping to change at line 424 ¶ |
* | | * |
* Invoking any calls other than @see serf_request_cancel before the setup | | * Invoking any calls other than @see serf_request_cancel before the setup |
* callback executes is not supported. | | * callback executes is not supported. |
*/ | | */ |
SERF_DECLARE(serf_request_t *) serf_connection_request_create( | | SERF_DECLARE(serf_request_t *) serf_connection_request_create( |
serf_connection_t *conn, | | serf_connection_t *conn, |
serf_request_setup_t setup, | | serf_request_setup_t setup, |
void *setup_baton); | | void *setup_baton); |
| | |
/** | | /** |
| | * Construct a request object for the @a conn connection, add it in the |
| | * list as the next to-be-written request before all unwritten requests. |
| | * |
| | * When it is time to deliver the request, the @a setup callback will |
| | * be invoked with the @a setup_baton passed into it to complete the |
| | * construction of the request object. |
| | * |
| | * If the request has not (yet) been delivered, then it may be canceled |
| | * with @see serf_request_cancel. |
| | * |
| | * Invoking any calls other than @see serf_request_cancel before the setup |
| | * callback executes is not supported. |
| | */ |
| | SERF_DECLARE(serf_request_t *) serf_connection_priority_request_create( |
| | serf_connection_t *conn, |
| | serf_request_setup_t setup, |
| | void *setup_baton); |
| | |
| | /** |
* Cancel the request specified by the @a request object. | | * Cancel the request specified by the @a request object. |
* | | * |
* If the request has been scheduled for delivery, then its response | | * If the request has been scheduled for delivery, then its response |
* handler will be run, passing NULL for the response bucket. | | * handler will be run, passing NULL for the response bucket. |
* | | * |
* If the request has already been (partially or fully) delivered, then | | * If the request has already been (partially or fully) delivered, then |
* APR_EBUSY is returned and the request is *NOT* canceled. To properly | | * APR_EBUSY is returned and the request is *NOT* canceled. To properly |
* cancel the request, the connection must be closed (by clearing or | | * cancel the request, the connection must be closed (by clearing or |
* destroying its associated pool). | | * destroying its associated pool). |
*/ | | */ |
| | |
skipping to change at line 360 ¶ | | skipping to change at line 488 ¶ |
* Update the @a handler and @a handler_baton for this @a request. | | * Update the @a handler and @a handler_baton for this @a request. |
* | | * |
* This can be called after the request has started processing - | | * This can be called after the request has started processing - |
* subsequent data will be delivered to this new handler. | | * subsequent data will be delivered to this new handler. |
*/ | | */ |
SERF_DECLARE(void) serf_request_set_handler( | | SERF_DECLARE(void) serf_request_set_handler( |
serf_request_t *request, | | serf_request_t *request, |
const serf_response_handler_t handler, | | const serf_response_handler_t handler, |
const void **handler_baton); | | const void **handler_baton); |
| | |
| | /** |
| | * Configure proxy server settings, to be used by all connections associate |
| | d |
| | * with the @a ctx serf context. |
| | * |
| | * The next connection will be created to connect to the proxy server |
| | * specified by @a address. The address must live at least as long as the |
| | * serf context. |
| | */ |
| | SERF_DECLARE(void) serf_config_proxy( |
| | serf_context_t *ctx, |
| | apr_sockaddr_t *address); |
| | |
/* ### maybe some connection control functions for flood? */ | | /* ### maybe some connection control functions for flood? */ |
| | |
| | /*** Special bucket creation functions ***/ |
| | |
| | /** |
| | * Create a bucket of type 'socket bucket'. |
| | * This is basically a wrapper around @a serf_bucket_socket_create, which |
| | * initializes the bucket using connection and/or context specific settings |
| | . |
| | */ |
| | SERF_DECLARE(serf_bucket_t *) serf_context_bucket_socket_create( |
| | serf_context_t *ctx, |
| | apr_socket_t *skt, |
| | serf_bucket_alloc_t *allocator); |
| | |
| | /** |
| | * Create a bucket of type 'request bucket'. |
| | * This is basically a wrapper around @a serf_bucket_request_create, which |
| | * initializes the bucket using request, connection and/or context specific |
| | * settings. |
| | * |
| | * If the host_url and/or user_agent options are set on the connection, |
| | * headers 'Host' and/or 'User-Agent' will be set on the request message. |
| | */ |
| | SERF_DECLARE(serf_bucket_t *) serf_request_bucket_request_create( |
| | serf_request_t *request, |
| | const char *method, |
| | const char *uri, |
| | serf_bucket_t *body, |
| | serf_bucket_alloc_t *allocator); |
| | |
/** @} */ | | /** @} */ |
| | |
/** | | /** |
* @defgroup serf buckets | | * @defgroup serf buckets |
* @ingroup serf | | * @ingroup serf |
* @{ | | * @{ |
*/ | | */ |
| | |
/** Pass as REQUESTED to the read function of a bucket to read, consume, | | /** Pass as REQUESTED to the read function of a bucket to read, consume, |
* and return all available data. | | * and return all available data. |
| | |
skipping to change at line 710 ¶ | | skipping to change at line 878 ¶ |
SERF_DECLARE(apr_status_t) serf_debug__record_read( | | SERF_DECLARE(apr_status_t) serf_debug__record_read( |
const serf_bucket_t *bucket, | | const serf_bucket_t *bucket, |
apr_status_t status); | | apr_status_t status); |
SERF_DECLARE(void) serf_debug__entered_loop(serf_bucket_alloc_t *allocator)
; | | SERF_DECLARE(void) serf_debug__entered_loop(serf_bucket_alloc_t *allocator)
; |
SERF_DECLARE(void) serf_debug__closed_conn(serf_bucket_alloc_t *allocator); | | SERF_DECLARE(void) serf_debug__closed_conn(serf_bucket_alloc_t *allocator); |
SERF_DECLARE(void) serf_debug__bucket_destroy(const serf_bucket_t *bucket); | | SERF_DECLARE(void) serf_debug__bucket_destroy(const serf_bucket_t *bucket); |
SERF_DECLARE(void) serf_debug__bucket_alloc_check(serf_bucket_alloc_t *allo
cator); | | SERF_DECLARE(void) serf_debug__bucket_alloc_check(serf_bucket_alloc_t *allo
cator); |
| | |
/* Version info */ | | /* Version info */ |
#define SERF_MAJOR_VERSION 0 | | #define SERF_MAJOR_VERSION 0 |
#define SERF_MINOR_VERSION 1 | | #define SERF_MINOR_VERSION 2 |
#define SERF_PATCH_VERSION 2 | | #define SERF_PATCH_VERSION 0 |
| | |
| | /* Version number string */ |
| | #define SERF_VERSION_STRING APR_STRINGIFY(SERF_MAJOR_VERSION) "." \ |
| | APR_STRINGIFY(SERF_MINOR_VERSION) "." \ |
| | APR_STRINGIFY(SERF_PATCH_VERSION) |
| | |
/** | | /** |
* Check at compile time if the Serf version is at least a certain | | * Check at compile time if the Serf version is at least a certain |
* level. | | * level. |
* @param major The major version component of the version checked | | * @param major The major version component of the version checked |
* for (e.g., the "1" of "1.3.0"). | | * for (e.g., the "1" of "1.3.0"). |
* @param minor The minor version component of the version checked | | * @param minor The minor version component of the version checked |
* for (e.g., the "3" of "1.3.0"). | | * for (e.g., the "3" of "1.3.0"). |
* @param patch The patch level component of the version checked | | * @param patch The patch level component of the version checked |
* for (e.g., the "0" of "1.3.0"). | | * for (e.g., the "0" of "1.3.0"). |
| | |
End of changes. 9 change blocks. |
2 lines changed or deleted | | 188 lines changed or added |
|
serf_bucket_types.h (0.1.2) | | serf_bucket_types.h (0.2.0) |
| | |
skipping to change at line 20 ¶ | | skipping to change at line 20 ¶ |
* distributed under the License is distributed on an "AS IS" BASIS, | | * distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and | | * See the License for the specific language governing permissions and |
* limitations under the License. | | * limitations under the License. |
*/ | | */ |
| | |
#ifndef SERF_BUCKET_TYPES_H | | #ifndef SERF_BUCKET_TYPES_H |
#define SERF_BUCKET_TYPES_H | | #define SERF_BUCKET_TYPES_H |
| | |
#include <apr_mmap.h> | | #include <apr_mmap.h> |
| | #include <apr_hash.h> |
| | |
/* this header and serf.h refer to each other, so take a little extra care
*/ | | /* this header and serf.h refer to each other, so take a little extra care
*/ |
#ifndef SERF_H | | #ifndef SERF_H |
#include "serf.h" | | #include "serf.h" |
#endif | | #endif |
| | |
#include "serf_declare.h" | | #include "serf_declare.h" |
| | |
/** | | /** |
* @file serf_bucket_types.h | | * @file serf_bucket_types.h |
| | |
skipping to change at line 57 ¶ | | skipping to change at line 58 ¶ |
serf_bucket_alloc_t *allocator); | | serf_bucket_alloc_t *allocator); |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_request_get_headers( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_request_get_headers( |
serf_bucket_t *request); | | serf_bucket_t *request); |
| | |
SERF_DECLARE(void) serf_bucket_request_become(serf_bucket_t *bucket, | | SERF_DECLARE(void) serf_bucket_request_become(serf_bucket_t *bucket, |
const char *method, | | const char *method, |
const char *uri, | | const char *uri, |
serf_bucket_t *body); | | serf_bucket_t *body); |
| | |
| | /** |
| | * Sets the root url of the remote host. If this request contains a relativ |
| | e |
| | * url, it will be prefixed with the root url to form an absolute url. |
| | * @a bucket is the request bucket. @a root_url is the absolute url of the |
| | * root of the remote host, without the closing '/'. |
| | */ |
| | SERF_DECLARE(void) serf_bucket_request_set_root(serf_bucket_t *bucket, |
| | const char *root_url); |
| | |
/* ==================================================================== */ | | /* ==================================================================== */ |
| | |
SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_response
; | | SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_response
; |
#define SERF_BUCKET_IS_RESPONSE(b) SERF_BUCKET_CHECK((b), response) | | #define SERF_BUCKET_IS_RESPONSE(b) SERF_BUCKET_CHECK((b), response) |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_response_create( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_response_create( |
serf_bucket_t *stream, | | serf_bucket_t *stream, |
serf_bucket_alloc_t *allocator); | | serf_bucket_alloc_t *allocator); |
| | |
#define SERF_HTTP_VERSION(major, minor) ((major) * 1000 + (minor)) | | #define SERF_HTTP_VERSION(major, minor) ((major) * 1000 + (minor)) |
| | |
skipping to change at line 159 ¶ | | skipping to change at line 169 ¶ |
| | |
/* ==================================================================== */ | | /* ==================================================================== */ |
| | |
SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_socket; | | SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_socket; |
#define SERF_BUCKET_IS_SOCKET(b) SERF_BUCKET_CHECK((b), socket) | | #define SERF_BUCKET_IS_SOCKET(b) SERF_BUCKET_CHECK((b), socket) |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_socket_create( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_socket_create( |
apr_socket_t *skt, | | apr_socket_t *skt, |
serf_bucket_alloc_t *allocator); | | serf_bucket_alloc_t *allocator); |
| | |
| | /** |
| | * Call @a progress_func every time bytes are read from the socket, pass |
| | * the number of bytes read. |
| | * |
| | * When using serf's bytes read & written progress indicator, pass |
| | * @a serf_context_progress_delta for progress_func and the serf_context fo |
| | r |
| | * progress_baton. |
| | */ |
| | SERF_DECLARE(void) serf_bucket_socket_set_read_progress_cb( |
| | serf_bucket_t *bucket, |
| | const serf_progress_t progress_func, |
| | void *progress_baton); |
| | |
/* ==================================================================== */ | | /* ==================================================================== */ |
| | |
SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_simple; | | SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_simple; |
#define SERF_BUCKET_IS_SIMPLE(b) SERF_BUCKET_CHECK((b), simple) | | #define SERF_BUCKET_IS_SIMPLE(b) SERF_BUCKET_CHECK((b), simple) |
| | |
typedef void (*serf_simple_freefunc_t)(void *baton, const char *data); | | typedef void (*serf_simple_freefunc_t)(void *baton, const char *data); |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_simple_create( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_simple_create( |
const char *data, apr_size_t len, | | const char *data, apr_size_t len, |
serf_simple_freefunc_t freefunc, | | serf_simple_freefunc_t freefunc, |
| | |
skipping to change at line 235 ¶ | | skipping to change at line 258 ¶ |
serf_bucket_t *headers_bucket, | | serf_bucket_t *headers_bucket, |
const char *header, | | const char *header, |
const char *value); | | const char *value); |
| | |
/** | | /** |
* Set, no copies. | | * Set, no copies. |
* | | * |
* Set the specified @a header and @a value into the bucket, without | | * Set the specified @a header and @a value into the bucket, without |
* copying either attribute. Both attributes should remain in scope at | | * copying either attribute. Both attributes should remain in scope at |
* least as long as the bucket. | | * least as long as the bucket. |
| | * |
| | * @note In the case where a header already exists this will result |
| | * in a reallocation and copy, @see serf_bucket_headers_setn. |
*/ | | */ |
SERF_DECLARE(void) serf_bucket_headers_setn( | | SERF_DECLARE(void) serf_bucket_headers_setn( |
serf_bucket_t *headers_bucket, | | serf_bucket_t *headers_bucket, |
const char *header, | | const char *header, |
const char *value); | | const char *value); |
| | |
/** | | /** |
* Set, extended: fine grained copy control of header and value. | | * Set, extended: fine grained copy control of header and value. |
* | | * |
* Set the specified @a header, with length @a header_size with the | | * Set the specified @a header, with length @a header_size with the |
* @a value, and length @a value_size, into the bucket. The header will | | * @a value, and length @a value_size, into the bucket. The header will |
* be copied if @a header_copy is set, and the value is copied if | | * be copied if @a header_copy is set, and the value is copied if |
* @a value_copy is set. If the values are not copied, then they should | | * @a value_copy is set. If the values are not copied, then they should |
* remain in scope at least as long as the bucket. | | * remain in scope at least as long as the bucket. |
| | * |
| | * If @a headers_bucket already contains a header with the same name |
| | * as @a header, then append @a value to the existing value, |
| | * separating with a comma (as per RFC 2616, section 4.2). In this |
| | * case, the new value must be allocated and the header re-used, so |
| | * behave as if @a value_copy were true and @a header_copy false. |
*/ | | */ |
SERF_DECLARE(void) serf_bucket_headers_setx( | | SERF_DECLARE(void) serf_bucket_headers_setx( |
serf_bucket_t *headers_bucket, | | serf_bucket_t *headers_bucket, |
const char *header, apr_size_t header_size, int header_copy, | | const char *header, apr_size_t header_size, int header_copy, |
const char *value, apr_size_t value_size, int value_copy); | | const char *value, apr_size_t value_size, int value_copy); |
| | |
SERF_DECLARE(const char *) serf_bucket_headers_get( | | SERF_DECLARE(const char *) serf_bucket_headers_get( |
serf_bucket_t *headers_bucket, | | serf_bucket_t *headers_bucket, |
const char *header); | | const char *header); |
| | |
| | |
skipping to change at line 321 ¶ | | skipping to change at line 353 ¶ |
| | |
SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_limit; | | SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_limit; |
#define SERF_BUCKET_IS_LIMIT(b) SERF_BUCKET_CHECK((b), limit) | | #define SERF_BUCKET_IS_LIMIT(b) SERF_BUCKET_CHECK((b), limit) |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_limit_create( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_limit_create( |
serf_bucket_t *stream, | | serf_bucket_t *stream, |
apr_size_t limit, | | apr_size_t limit, |
serf_bucket_alloc_t *allocator); | | serf_bucket_alloc_t *allocator); |
| | |
/* ==================================================================== */ | | /* ==================================================================== */ |
| | #define SERF_SSL_CERT_NOTYETVALID 1 |
| | #define SERF_SSL_CERT_EXPIRED 2 |
| | #define SERF_SSL_CERT_UNKNOWNCA 4 |
| | #define SERF_SSL_CERT_SELF_SIGNED 8 |
| | #define SERF_SSL_CERT_UNKNOWN_FAILURE 16 |
| | |
SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_ssl_encr
ypt; | | SERF_DECLARE_DATA extern const serf_bucket_type_t serf_bucket_type_ssl_encr
ypt; |
#define SERF_BUCKET_IS_SSL_ENCRYPT(b) SERF_BUCKET_CHECK((b), ssl_encrypt) | | #define SERF_BUCKET_IS_SSL_ENCRYPT(b) SERF_BUCKET_CHECK((b), ssl_encrypt) |
| | |
typedef struct serf_ssl_context_t serf_ssl_context_t; | | typedef struct serf_ssl_context_t serf_ssl_context_t; |
| | typedef struct serf_ssl_certificate_t serf_ssl_certificate_t; |
| | |
typedef apr_status_t (*serf_ssl_need_client_cert_t)(void *data, | | typedef apr_status_t (*serf_ssl_need_client_cert_t)(void *data, |
const char **cert_path)
; | | const char **cert_path)
; |
| | |
typedef apr_status_t (*serf_ssl_need_cert_password_t)(void *data, | | typedef apr_status_t (*serf_ssl_need_cert_password_t)(void *data, |
const char *cert_path
, | | const char *cert_path
, |
const char **password
); | | const char **password
); |
| | |
| | typedef apr_status_t |
| | (*serf_ssl_need_server_cert_t)(void *data, |
| | int failures, |
| | const serf_ssl_certificate_t *cert); |
| | |
SERF_DECLARE(void) | | SERF_DECLARE(void) |
serf_ssl_client_cert_provider_set(serf_ssl_context_t *context, | | serf_ssl_client_cert_provider_set(serf_ssl_context_t *context, |
serf_ssl_need_client_cert_t callback, | | serf_ssl_need_client_cert_t callback, |
void *data, | | void *data, |
void *cache_pool); | | void *cache_pool); |
| | |
SERF_DECLARE(void) | | SERF_DECLARE(void) |
serf_ssl_client_cert_password_set(serf_ssl_context_t *context, | | serf_ssl_client_cert_password_set(serf_ssl_context_t *context, |
serf_ssl_need_cert_password_t callback, | | serf_ssl_need_cert_password_t callback, |
void *data, | | void *data, |
void *cache_pool); | | void *cache_pool); |
| | /** |
| | * Set a callback to override the default SSL server certificate validation |
| | * algorithm. |
| | */ |
| | SERF_DECLARE(void) |
| | serf_ssl_server_cert_callback_set(serf_ssl_context_t *context, |
| | serf_ssl_need_server_cert_t callback, |
| | void *data); |
| | |
| | /** |
| | * Use the default root CA certificates as included with the OpenSSL librar |
| | y. |
| | */ |
| | SERF_DECLARE(apr_status_t) |
| | serf_ssl_use_default_certificates(serf_ssl_context_t *context); |
| | |
| | /** |
| | * Extract the fields of the issuer in a table with keys (E, CN, OU, O, L, |
| | * ST and C). The returned table will be allocated in @a pool. |
| | */ |
| | SERF_DECLARE(apr_hash_t *) |
| | serf_ssl_cert_issuer(const serf_ssl_certificate_t *cert, apr_pool_t *pool); |
| | |
| | /** |
| | * Extract the fields of the subject in a table with keys (E, CN, OU, O, L, |
| | * ST and C). The returned table will be allocated in @a pool. |
| | */ |
| | SERF_DECLARE(apr_hash_t *) |
| | serf_ssl_cert_subject(const serf_ssl_certificate_t *cert, apr_pool_t *pool) |
| | ; |
| | |
| | /** |
| | * Extract the fields of the certificate in a table with keys (sha1, notBef |
| | ore, |
| | * notAfter). The returned table will be allocated in @a pool. |
| | */ |
| | SERF_DECLARE(apr_hash_t *) |
| | serf_ssl_cert_certificate(const serf_ssl_certificate_t *cert, apr_pool_t *p |
| | ool); |
| | |
| | /** |
| | * Load a CA certificate file from a path @a file_path. If the file was loa |
| | ded |
| | * and parsed correctly, a certificate @a cert will be created and returned |
| | . |
| | * This certificate object will be alloced in @a pool. |
| | */ |
| | SERF_DECLARE(apr_status_t) |
| | serf_ssl_load_cert_file(serf_ssl_certificate_t **cert, const char *file_pat |
| | h, |
| | apr_pool_t *pool); |
| | |
| | /** |
| | * Adds the certificate @a cert to the list of trusted certificates in |
| | * @a ssl_ctx that will be used for verification. |
| | * See also @a serf_ssl_load_cert_file. |
| | */ |
| | SERF_DECLARE(apr_status_t) |
| | serf_ssl_trust_cert(serf_ssl_context_t *ssl_ctx, serf_ssl_certificate_t *ce |
| | rt); |
| | |
SERF_DECLARE(serf_bucket_t *) serf_bucket_ssl_encrypt_create( | | SERF_DECLARE(serf_bucket_t *) serf_bucket_ssl_encrypt_create( |
serf_bucket_t *stream, | | serf_bucket_t *stream, |
serf_ssl_context_t *ssl_context, | | serf_ssl_context_t *ssl_context, |
serf_bucket_alloc_t *allocator); | | serf_bucket_alloc_t *allocator); |
| | |
SERF_DECLARE(serf_ssl_context_t *) serf_bucket_ssl_encrypt_context_get( | | SERF_DECLARE(serf_ssl_context_t *) serf_bucket_ssl_encrypt_context_get( |
serf_bucket_t *bucket); | | serf_bucket_t *bucket); |
| | |
/* ==================================================================== */ | | /* ==================================================================== */ |
| | |
End of changes. 9 change blocks. |
0 lines changed or deleted | | 105 lines changed or added |
|