serf.h   serf.h 
skipping to change at line 51 skipping to change at line 51
typedef struct serf_bucket_type_t serf_bucket_type_t; typedef struct serf_bucket_type_t serf_bucket_type_t;
typedef struct serf_bucket_alloc_t serf_bucket_alloc_t; typedef struct serf_bucket_alloc_t serf_bucket_alloc_t;
typedef struct serf_connection_t serf_connection_t; typedef struct serf_connection_t serf_connection_t;
typedef struct serf_listener_t serf_listener_t; typedef struct serf_listener_t serf_listener_t;
typedef struct serf_incoming_t serf_incoming_t; typedef struct serf_incoming_t serf_incoming_t;
typedef struct serf_incoming_request_t serf_incoming_request_t; typedef struct serf_incoming_request_t serf_incoming_request_t;
typedef struct serf_request_t serf_request_t; typedef struct serf_request_t serf_request_t;
#if 0
typedef struct serf_connection_type_t serf_connection_type_t;
typedef struct serf_protocol_t serf_protocol_t;
typedef struct serf_protocol_type_t serf_protocol_type_t;
#endif /* Connection and protocol API v2 */
typedef struct serf_config_t serf_config_t;
/** /**
* @defgroup serf high-level constructs * @defgroup serf high-level constructs
* @ingroup serf * @ingroup serf
* @{ * @{
*/ */
/** /**
* Serf-specific error codes * Serf-specific error codes
*/ */
#define SERF_ERROR_RANGE 100 #define SERF_ERROR_RANGE 100
skipping to change at line 89 skipping to change at line 97
#define SERF_ERROR_DECOMPRESSION_FAILED (SERF_ERROR_START + 4) #define SERF_ERROR_DECOMPRESSION_FAILED (SERF_ERROR_START + 4)
/* This code is for when a response received from a http server is not in /* This code is for when a response received from a http server is not in
* http-compliant syntax. */ * http-compliant syntax. */
#define SERF_ERROR_BAD_HTTP_RESPONSE (SERF_ERROR_START + 5) #define SERF_ERROR_BAD_HTTP_RESPONSE (SERF_ERROR_START + 5)
/* The server sent less data than what was announced. */ /* The server sent less data than what was announced. */
#define SERF_ERROR_TRUNCATED_HTTP_RESPONSE (SERF_ERROR_START + 6) #define SERF_ERROR_TRUNCATED_HTTP_RESPONSE (SERF_ERROR_START + 6)
/* The proxy server returned an error while setting up the SSL tunnel. */ /* The proxy server returned an error while setting up the SSL tunnel. */
#define SERF_ERROR_SSLTUNNEL_SETUP_FAILED (SERF_ERROR_START + 7) #define SERF_ERROR_SSLTUNNEL_SETUP_FAILED (SERF_ERROR_START + 7)
/* The server unexpectedly closed the connection prematurely. */ /* The server unexpectedly closed the connection prematurely. */
#define SERF_ERROR_ABORTED_CONNECTION (SERF_ERROR_START + 8) #define SERF_ERROR_ABORTED_CONNECTION (SERF_ERROR_START + 8)
/* Generic 'The line too long'. Used internally. */
#define SERF_ERROR_LINE_TOO_LONG (SERF_ERROR_START + 9)
/* The HTTP response status line too long. */
#define SERF_ERROR_STATUS_LINE_TOO_LONG (SERF_ERROR_START + 10)
/* The HTTP response header too long. */
#define SERF_ERROR_RESPONSE_HEADER_TOO_LONG (SERF_ERROR_START + 11)
/* The connection to the server timed out. */
#define SERF_ERROR_CONNECTION_TIMEDOUT (SERF_ERROR_START + 12)
/* SSL certificates related errors */ /* SSL certificates related errors */
#define SERF_ERROR_SSL_CERT_FAILED (SERF_ERROR_START + 70) #define SERF_ERROR_SSL_CERT_FAILED (SERF_ERROR_START + 70)
/* SSL communications related errors */ /* SSL communications related errors */
#define SERF_ERROR_SSL_COMM_FAILED (SERF_ERROR_START + 71) #define SERF_ERROR_SSL_COMM_FAILED (SERF_ERROR_START + 71)
/* SSL handshake failed */
#define SERF_ERROR_SSL_SETUP_FAILED (SERF_ERROR_START + 72)
/* Serf-internal error code, raised when the server initiates SSL renegotia
tion
on a connection that uses HTTP pipelining. */
#define SERF_ERROR_SSL_NEGOTIATE_IN_PROGRESS (SERF_ERROR_START + 73)
/* General authentication related errors */ /* General authentication related errors */
#define SERF_ERROR_AUTHN_FAILED (SERF_ERROR_START + 90) #define SERF_ERROR_AUTHN_FAILED (SERF_ERROR_START + 90)
/* None of the available authn mechanisms for the request are supported */ /* None of the available authn mechanisms for the request are supported */
#define SERF_ERROR_AUTHN_NOT_SUPPORTED (SERF_ERROR_START + 91) #define SERF_ERROR_AUTHN_NOT_SUPPORTED (SERF_ERROR_START + 91)
/* Authn was requested by the server but the header lacked some attribute */ /* Authn was requested by the server but the header lacked some attribute */
#define SERF_ERROR_AUTHN_MISSING_ATTRIBUTE (SERF_ERROR_START + 92) #define SERF_ERROR_AUTHN_MISSING_ATTRIBUTE (SERF_ERROR_START + 92)
/* Authentication handler initialization related errors */ /* Authentication handler initialization related errors */
#define SERF_ERROR_AUTHN_INITALIZATION_FAILED (SERF_ERROR_START + 93) #define SERF_ERROR_AUTHN_INITALIZATION_FAILED (SERF_ERROR_START + 93)
/* The user credentials were rejected by the server */
#define SERF_ERROR_AUTHN_CREDENTIALS_REJECTED (SERF_ERROR_START + 94)
/* Error code reserved for use in the test suite. */ /* Error code reserved for use in the test suite. */
#define SERF_ERROR_ISSUE_IN_TESTSUITE (SERF_ERROR_START + 99) #define SERF_ERROR_ISSUE_IN_TESTSUITE (SERF_ERROR_START + 99)
/* This macro groups errors potentially raised when reading a http response . */ /* This macro groups errors potentially raised when reading a http response . */
#define SERF_BAD_RESPONSE_ERROR(status) ((status) \ #define SERF_BAD_RESPONSE_ERROR(status) ((status) \
&& ((SERF_ERROR_DECOMPRESSION_FAILED == (status)) \ && ((SERF_ERROR_DECOMPRESSION_FAILED == (status)) \
||(SERF_ERROR_BAD_HTTP_RESPONSE == (status)) \ ||(SERF_ERROR_BAD_HTTP_RESPONSE == (status)) \
||(SERF_ERROR_TRUNCATED_HTTP_RESPONSE == (status)))) ||(SERF_ERROR_TRUNCATED_HTTP_RESPONSE == (status))))
/** /**
skipping to change at line 574 skipping to change at line 600
serf_request_t *serf_connection_priority_request_create( serf_request_t *serf_connection_priority_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);
/** Returns detected network latency for the @a conn connection. Negative /** Returns detected network latency for the @a conn connection. Negative
* value means that latency is unknwon. * value means that latency is unknwon.
*/ */
apr_interval_time_t serf_connection_get_latency(serf_connection_t *conn); apr_interval_time_t serf_connection_get_latency(serf_connection_t *conn);
/**
* Returns the number of requests waiting to be sent over connection CONN.
*/
unsigned int serf_connection_queued_requests(serf_connection_t *conn);
/**
* Returns the total number of requests for which a response hasn't been
* received yet on connection CONN. This includes requests:
* - that are queued but not sent.
* - that have been sent but no response has been completely received yet.
*/
unsigned int serf_connection_pending_requests(serf_connection_t *conn);
/** Check if a @a request has been completely written. /** Check if a @a request has been completely written.
* *
* Returns APR_SUCCESS if the request was written completely on the connect ion. * Returns APR_SUCCESS if the request was written completely on the connect ion.
* Returns APR_EBUSY if the request is not yet or partially written. * Returns APR_EBUSY if the request is not yet or partially written.
*/ */
apr_status_t serf_request_is_written( apr_status_t serf_request_is_written(
serf_request_t *request); serf_request_t *request);
/** /**
* Cancel the request specified by the @a request object. * Cancel the request specified by the @a request object.
skipping to change at line 866 skipping to change at line 905
* APR_EAGAIN will never be returned. * APR_EAGAIN will never be returned.
*/ */
apr_status_t (*peek)(serf_bucket_t *bucket, apr_status_t (*peek)(serf_bucket_t *bucket,
const char **data, apr_size_t *len); const char **data, apr_size_t *len);
/** /**
* Destroy @a bucket, along with any associated resources. * Destroy @a bucket, along with any associated resources.
*/ */
void (*destroy)(serf_bucket_t *bucket); void (*destroy)(serf_bucket_t *bucket);
/* The following members are valid only if read_bucket equals to
* serf_buckets_are_v2(). */
/* Real pointer to read_bucket() method when read_bucket is
* serf_buckets_are_v2(). */
serf_bucket_t * (*read_bucket_v2)(serf_bucket_t *bucket,
const serf_bucket_type_t *type);
/* Provides a reference to a config object containing all configuration
* values relevant for this bucket.
*
* @since New in 1.4.
*/
apr_status_t (*set_config)(serf_bucket_t *bucket, serf_config_t *config
);
/* ### apr buckets have 'copy', 'split', and 'setaside' functions. /* ### apr buckets have 'copy', 'split', and 'setaside' functions.
### not sure whether those will be needed in this bucket model. ### not sure whether those will be needed in this bucket model.
*/ */
}; };
/** /**
* Should the use and lifecycle of buckets be tracked? * Should the use and lifecycle of buckets be tracked?
* *
* When tracking, the system will ensure several semantic requirements * When tracking, the system will ensure several semantic requirements
* of bucket use: * of bucket use:
skipping to change at line 892 skipping to change at line 946
* - buckets should not be destroyed before they return APR_EOF unless * - buckets should not be destroyed before they return APR_EOF unless
* the connection is closed for some reason. * the connection is closed for some reason.
* *
* Undefine this symbol to avoid the tracking (and a performance gain). * Undefine this symbol to avoid the tracking (and a performance gain).
* *
* ### we may want to examine when/how we provide this. should it always * ### we may want to examine when/how we provide this. should it always
* ### be compiled in? and apps select it before including this header? * ### be compiled in? and apps select it before including this header?
*/ */
/* #define SERF_DEBUG_BUCKET_USE */ /* #define SERF_DEBUG_BUCKET_USE */
/* Predefined value for read_bucket vtable member to declare v2 buckets
* vtable.
*
* @since New in 1.4.
*/
serf_bucket_t * serf_buckets_are_v2(serf_bucket_t *bucket,
const serf_bucket_type_t *type);
/* Internal macros for tracking bucket use. */ /* Internal macros for tracking bucket use. */
#ifdef SERF_DEBUG_BUCKET_USE #ifdef SERF_DEBUG_BUCKET_USE
#define SERF__RECREAD(b,s) serf_debug__record_read(b,s) #define SERF__RECREAD(b,s) serf_debug__record_read(b,s)
#else #else
#define SERF__RECREAD(b,s) (s) #define SERF__RECREAD(b,s) (s)
#endif #endif
#define serf_bucket_read(b,r,d,l) SERF__RECREAD(b, (b)->type->read(b,r,d,l) ) #define serf_bucket_read(b,r,d,l) SERF__RECREAD(b, (b)->type->read(b,r,d,l) )
#define serf_bucket_readline(b,a,f,d,l) \ #define serf_bucket_readline(b,a,f,d,l) \
SERF__RECREAD(b, (b)->type->readline(b,a,f,d,l)) SERF__RECREAD(b, (b)->type->readline(b,a,f,d,l))
#define serf_bucket_read_iovec(b,r,s,v,u) \ #define serf_bucket_read_iovec(b,r,s,v,u) \
SERF__RECREAD(b, (b)->type->read_iovec(b,r,s,v,u)) SERF__RECREAD(b, (b)->type->read_iovec(b,r,s,v,u))
#define serf_bucket_read_for_sendfile(b,r,h,f,o,l) \ #define serf_bucket_read_for_sendfile(b,r,h,f,o,l) \
SERF__RECREAD(b, (b)->type->read_for_sendfile(b,r,h,f,o,l)) SERF__RECREAD(b, (b)->type->read_for_sendfile(b,r,h,f,o,l))
#define serf_bucket_read_bucket(b,t) ((b)->type->read_bucket(b,t)) #define serf_bucket_read_bucket(b,t) ((b)->type->read_bucket(b,t))
#define serf_bucket_peek(b,d,l) ((b)->type->peek(b,d,l)) #define serf_bucket_peek(b,d,l) ((b)->type->peek(b,d,l))
#define serf_bucket_destroy(b) ((b)->type->destroy(b)) #define serf_bucket_destroy(b) ((b)->type->destroy(b))
#define serf_bucket_set_config(b,c) \
((b)->type->read_bucket == serf_buckets_are_v2 ? \
(b)->type->set_config(b,c) : \
APR_ENOTIMPL)
/** /**
* Check whether a real error occurred. Note that bucket read functions * Check whether a real error occurred. Note that bucket read functions
* can return EOF and EAGAIN as part of their "normal" operation, so they * can return EOF and EAGAIN as part of their "normal" operation, so they
* should not be considered an error. * should not be considered an error.
*/ */
#define SERF_BUCKET_READ_ERROR(status) ((status) \ #define SERF_BUCKET_READ_ERROR(status) ((status) \
&& !APR_STATUS_IS_EOF(status) \ && !APR_STATUS_IS_EOF(status) \
&& !APR_STATUS_IS_EAGAIN(status) \ && !APR_STATUS_IS_EAGAIN(status) \
&& (SERF_ERROR_WAIT_CONN != status) ) && (SERF_ERROR_WAIT_CONN != status) )
skipping to change at line 937 skipping to change at line 1003
/** the allocator used for this bucket (needed at destroy time) */ /** the allocator used for this bucket (needed at destroy time) */
serf_bucket_alloc_t *allocator; serf_bucket_alloc_t *allocator;
}; };
/** /**
* Generic macro to construct "is TYPE" macros. * Generic macro to construct "is TYPE" macros.
*/ */
#define SERF_BUCKET_CHECK(b, btype) ((b)->type == &serf_bucket_type_ ## bty pe) #define SERF_BUCKET_CHECK(b, btype) ((b)->type == &serf_bucket_type_ ## bty pe)
/** @} */
/** /**
* Notification callback for a block that was not returned to the bucket * Notification callback for a block that was not returned to the bucket
* allocator when its pool was destroyed. * allocator when its pool was destroyed.
* *
* The block of memory is given by @a block. The baton provided when the * The block of memory is given by @a block. The baton provided when the
* allocator was constructed is passed as @a unfreed_baton. * allocator was constructed is passed as @a unfreed_baton.
*/ */
typedef void (*serf_unfreed_func_t)( typedef void (*serf_unfreed_func_t)(
void *unfreed_baton, void *unfreed_baton,
void *block); void *block);
skipping to change at line 995 skipping to change at line 1063
* Since it is entirely possible for a line to be broken by APR_EAGAIN, * Since it is entirely possible for a line to be broken by APR_EAGAIN,
* this structure can be used to accumulate the data until a complete line * this structure can be used to accumulate the data until a complete line
* has been read from a bucket. * has been read from a bucket.
*/ */
/* This limit applies to the line buffer functions. If an application needs /* This limit applies to the line buffer functions. If an application needs
* longer lines, then they will need to manually handle line buffering. * longer lines, then they will need to manually handle line buffering.
*/ */
#define SERF_LINEBUF_LIMIT 8000 #define SERF_LINEBUF_LIMIT 8000
typedef struct { typedef struct serf_linebuf_t {
/* Current state of the buffer. */ /* Current state of the buffer. */
enum { enum {
SERF_LINEBUF_EMPTY, SERF_LINEBUF_EMPTY,
SERF_LINEBUF_READY, SERF_LINEBUF_READY,
SERF_LINEBUF_PARTIAL, SERF_LINEBUF_PARTIAL,
SERF_LINEBUF_CRLF_SPLIT SERF_LINEBUF_CRLF_SPLIT
} state; } state;
/* How much of the buffer have we used? */ /* How much of the buffer have we used? */
apr_size_t used; apr_size_t used;
/* The line is read into this buffer, minus CR/LF */ /* The line is read into this buffer, minus CR/LF.
*
* NOTE: Before serf 2.0 buffer IS NOT NUL terminated
* and @a used should be used to find line length.
*
* Since serf 2.0 buffer is always NUL terminated.
**/
char line[SERF_LINEBUF_LIMIT]; char line[SERF_LINEBUF_LIMIT];
} serf_linebuf_t; } serf_linebuf_t;
/** /**
* Initialize the @a linebuf structure. * Initialize the @a linebuf structure.
*/ */
void serf_linebuf_init(serf_linebuf_t *linebuf); void serf_linebuf_init(serf_linebuf_t *linebuf);
/** /**
skipping to change at line 1031 skipping to change at line 1105
* acceptable for this fetch. * acceptable for this fetch.
* *
* ### we should return a data/len pair so that we can avoid a copy, * ### we should return a data/len pair so that we can avoid a copy,
* ### rather than having callers look into our state and line buffer. * ### rather than having callers look into our state and line buffer.
*/ */
apr_status_t serf_linebuf_fetch( apr_status_t serf_linebuf_fetch(
serf_linebuf_t *linebuf, serf_linebuf_t *linebuf,
serf_bucket_t *bucket, serf_bucket_t *bucket,
int acceptable); int acceptable);
/*** Configuration store declarations ***/
typedef const apr_uint32_t serf_config_key_t;
/* The left-most byte of the int32 key holds the category (bit flags).
The other bytes are a number representing the key.
Serf will not use the second byte for its own keys, so applications can
use this byte to define custom keys.
*/
typedef enum {
SERF_CONFIG_PER_CONTEXT = 0x10000000,
SERF_CONFIG_PER_HOST = 0x20000000,
SERF_CONFIG_PER_CONNECTION = 0x40000000,
} serf_config_categories_t;
#define SERF_CONFIG_HOST_NAME (SERF_CONFIG_PER_HOST | 0x000001)
#define SERF_CONFIG_HOST_PORT (SERF_CONFIG_PER_HOST | 0x000002)
#define SERF_CONFIG_CONN_LOCALIP (SERF_CONFIG_PER_CONNECTION | 0x000001)
#define SERF_CONFIG_CONN_REMOTEIP (SERF_CONFIG_PER_CONNECTION | 0x000002)
#define SERF_CONFIG_CONN_PIPELINING (SERF_CONFIG_PER_CONNECTION | 0x000003)
#define SERF_CONFIG_CTX_LOGBATON (SERF_CONFIG_PER_CONTEXT | 0x000001)
/* Configuration values stored in the configuration store:
Category Key Value Type
-------- --- ----------
Context logbaton log_baton_t *
Context proxyauthn apr_hash_t * (not implemented)
Connection localip const char *
Connection remoteip const char *
Host hostname const char *
Host hostport const char *
Host authn apr_hash_t * (not implemented)
*/
/* Set a value of type const char * for configuration item CATEGORY+KEY.
@since New in 1.4.
*/
apr_status_t serf_config_set_string(serf_config_t *config,
serf_config_key_t key,
const char *value);
/* Copy a value of type const char * and set it for configuration item
CATEGORY+KEY.
@since New in 1.4.
*/
apr_status_t serf_config_set_stringc(serf_config_t *config,
serf_config_key_t key,
const char *value);
/* Set a value of generic type for configuration item CATEGORY+KEY.
See @a serf_set_config_string for COPY_FLAGS description.
@since New in 1.4.
*/
apr_status_t serf_config_set_stringf(serf_config_t *config,
serf_config_key_t key,
const char *fmt, ...);
/* Set a value of generic type for configuration item CATEGORY+KEY.
See @a serf_set_config_string for COPY_FLAGS description.
@since New in 1.4.
*/
apr_status_t serf_config_set_object(serf_config_t *config,
serf_config_key_t key,
void *value);
/* Get the value for configuration item CATEGORY+KEY. The value's type will
be fixed, see the above table.
Returns APR_EINVAL when getting a key from a category that this config
object doesn't contain, APR_SUCCESS otherwise.
@since New in 1.4.
*/
apr_status_t serf_config_get_string(serf_config_t *config,
serf_config_key_t key,
const char **value);
apr_status_t serf_config_get_object(serf_config_t *config,
serf_config_key_t key,
void **value);
/* Remove the value for configuration item CATEGORY+KEY from the configurat
ion
store.
@since New in 1.4.
*/
apr_status_t serf_config_remove_value(serf_config_t *config,
serf_config_key_t key);
/*** Serf logging API ***/
/* Ordered list of log levels, more detailed log levels include less
detailed levels. (e.g. level DEBUG also logs ERROR, WARNING & INFO messa
ges).
*/
#define SERF_LOG_ERROR 0x0001
#define SERF_LOG_WARNING 0x0002
#define SERF_LOG_INFO 0x0004
#define SERF_LOG_DEBUG 0x0008
#define SERF_LOG_NONE 0x0000
/* List of components, used as a mask. */
#define SERF_LOGCOMP_ALL_MSG 0xFFFF /* All components, including message
content */
#define SERF_LOGCOMP_RAWMSG 0x0100 /* logs requests and responses directly
on
the socket layer. */
#define SERF_LOGCOMP_SSLMSG 0x0200 /* logs decrypted requests and response
s. */
#define SERF_LOGCOMP_ALL 0x00FF /* All components, no message content *
/
#define SERF_LOGCOMP_SSL 0x0001 /* The SSL component */
#define SERF_LOGCOMP_AUTHN 0x0002 /* Authentication components */
#define SERF_LOGCOMP_CONN 0x0004 /* Connection-related events */
#define SERF_LOGCOMP_COMPR 0x0008 /* The compression (deflate) component
*/
#define SERF_LOGCOMP_NONE 0x0000
typedef struct serf_log_output_t serf_log_output_t;
typedef struct serf_log_layout_t serf_log_layout_t;
/* The default log layout. It's format is:
[TIMESTAMP] [LOG LEVEL] [l:LOCALIP:PORT r:REMOTEIP:PORT] FILENAME MESSAG
E
*/
#define SERF_LOG_DEFAULT_LAYOUT ((serf_log_layout_t *)NULL)
/* TODO: it's not yet possible to define custom layouts */
/* Create a stream output for log info. This can be used with one of the
standard streams stderr or stdout.
LAYOUT should be SERF_LOG_DEFAULT_LAYOUT (there's no alternative for now
).
The lifetime of POOL should be atleast the same as that of CTX, but it c
an
be used by multiple contexts. */
apr_status_t serf_logging_create_stream_output(serf_log_output_t **output,
serf_context_t *ctx,
apr_uint32_t level,
apr_uint32_t comp_mask,
serf_log_layout_t *layout,
FILE *fp,
apr_pool_t *pool);
/* Define an output handler for a log level and a (set of) log component(s)
.
OUTPUT is the object returned by one of the serf_logging_create_XXX_outp
ut
factory functions. */
apr_status_t serf_logging_add_output(serf_context_t *ctx,
const serf_log_output_t *output);
/*** Connection and protocol API v2 ***/
#if 0
/* ### docco. */
apr_status_t serf_connection_switch_protocol(
serf_connection_t *conn,
serf_protocol_t *proto
/* ### other params? */
);
/* ### docco. */
typedef struct serf_queue_item_t serf_queue_item_t;
/**
* Present a response to the application.
*
* Called when a response has been processed by the current protocol (to an
y
* extent necessary) and is ready for the application to handle.
*
* Note: @a request may be NULL if this response is server-pushed rather th
an
* specifically requested.
*/
typedef apr_status_t (*serf_begin_response_t)(
/* ### args not settled */
void **handler_baton,
serf_request_t *request,
serf_bucket_t *response,
apr_pool_t *scratch_pool);
/* ### better name? */
typedef apr_status_t (*serf_handler_t)(
/* ### args not settled */
void *handler_baton,
serf_bucket_t *response,
apr_pool_t *scratch_pool);
struct serf_protocol_type_t {
/** Name of this protocol type. */
const char *name;
/** Vtable version. */
int version;
#define SERF_PROTOCOL_TYPE_VERSION 1
/**
* When a pending request reaches the front of the queue, then it becom
es
* "active". This callback is used to build/provide the protocol-specif
ic
* request bucket.
*
* ### more docco
*/
apr_status_t (*serf_request_activate_t)(
serf_bucket_t **request_bkt,
serf_queue_item_t *request_qi,
void *request_baton,
serf_bucket_alloc_t *request_bktalloc,
apr_pool_t *scratch_pool);
/**
* Construct a protocol parsing bucket, for passing to the process_data
* vtable entry.
*
* When data arrives on the connection, and a parser is not already
* processing the connection's data, then build a new bucket to parse
* this incoming data (according to the protocol).
*/
serf_bucket_t * (*build_parser)(serf_protocol_t *proto,
apr_pool_t *scratch_pool);
/**
* The protocol should parse all available response data, per the proto
col.
*
* This is called when data has become available to the parser. The pro
tocol
* should read all available data before returning.
*/
apr_status_t (*process_data)(serf_protocol_t *proto,
serf_bucket_t *parser,
apr_pool_t *scratch_pool);
};
/**
* Activate an HTTP request when it reaches the front of the queue.
*
* ### more docco
*/
typedef apr_status_t (*serf_http_activate_t)(
serf_bucket_t **body_bkt,
serf_bucket_t *request_bkt, /* type REQUEST */
serf_queue_item_t *request_qi,
void *request_baton,
serf_bucket_alloc_t *request_bktalloc,
apr_pool_t *scratch_pool);
/**
* Create a new connection and associated HTTP protocol parser.
*
* The new connection/protocol will be associated with @a ctx. It will be
* opened once a request is placed into its outgoing queue. The connection
* will use @a hostname and @a port for the origin server. If
* @a proxy_hostname is not NULL, then all requests will go through the
* proxy specified by @a proxy_hostname and @a proxy_port.
*
* DNS lookups for @a hostname and @a proxy_hostname will be performed
* when the connection first opened, then cached in case the connection
* ever needs to be re-opened.
*
* When a queued request reaches the front of the queue, and is ready for
* delivery, then @a activate_cb will be called to prepare the request.
*
* @a authn_types specifies the types of authentication allowed on this
* connection. Normally, it should be SERF_AUTHN_ALL. When authentication
* credentials are required (for the origin server or the proxy), then
* @a creds_cb will be called with @a app_baton.
*
* When the connection is closed (upon request or because of an error),
* then @a closed_cb will be called with @a app_baton.
*
* The connection and protocol paresr will be allocated in @a result_pool.
* This function will use @a scratch_pool for temporary allocations.
*/
apr_status_t serf_http_protocol_create(
serf_protocol_t **proto,
serf_context_t *ctx,
const char *hostname,
int port,
const char *proxy_hostname,
int proxy_port,
int authn_types,
serf_http_activate_t activate_cb,
/* ### do we need different params for CREDS_CB and CLOSED_CB ? */
serf_credentials_callback_t creds_cb,
serf_connection_closed_t closed_cb,
void *app_baton,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* ### docco. create http proto parser with an encrypted connection. */
apr_status_t serf_https_protocol_create(
serf_protocol_t **proto,
serf_context_t *ctx,
const char *hostname,
int port,
/* ### client certs, credential validation callbacks, etc */
serf_connection_closed_t closed,
void *closed_baton,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* ### docco. queue up an http request. */
serf_queue_item_t *serf_http_request_queue(
serf_protocol_t *proto,
int priority,
void *request_baton);
/**
* ### rationalize against "serf connections and request" group above
*
* @defgroup serf connections
* @ingroup serf
* @{
*/
struct serf_connection_type_t {
/** Name of this connection type. */
const char *name;
/** Vtable version. */
int version;
#define SERF_CONNECTION_TYPE_VERSION 1
/**
* Initiate a connection to the server.
*
* ### docco. note async. note that request(s) may be queued.
* ### can we somehow defer the SSL tunnel's CONNECT to the higher
* ### layer? then have the HTTP protocol layer wrap a CONN_PLAIN
* ### into a CONN_TLS connection once the tunnel is established?
*/
apr_status_t (*connect)(serf_connection_t *conn);
/**
* Returns a bucket for reading from this connection.
*
* This bucket remains constant for the lifetime of the connection. It
has
* built-in BARRIER bucket protection, so it can safely be "destroyed"
* without problem (and a later call to this vtable function will retur
n
* the same bucket again).
*
* For all intents and purposes, this bucket is borrowed by the caller.
*
* This bucket effectively maps to the underlying socket, or possibly t
o
* a decrypting bucket layered over the socket.
*/
serf_bucket_t * (*get_read_bucket)(serf_connection_t *conn);
/**
* Write some data into into the connection.
*
* Attempt to write a number of iovecs into the connection. The number
of
* vectors *completely* written will be returned in @a vecs_written. If
that
* equals @a vecs_size, then @a last_written will be set to 0. If it is
less
* (not all iovecs were written), then the amount written from the next
,
* incompletely written iovec is returned in @a last_written.
*
* In other words, the first byte of unwritten content is located at:
*
* <pre>
* first = vecs[vecs_written][last_written];
* </pre>
*
* If all bytes are written, then APR_SUCCESS is returned. If only a po
rtion
* was written, then APR_EAGAIN will be returned.
*/
apr_status_t (*writev)(serf_connection_t *conn,
int vecs_size, struct iovec *vecs,
int *vecs_written, apr_size_t *last_written);
};
#endif /* Connection and protocol API v2 */
/** @} */ /** @} */
/* Internal functions for bucket use and lifecycle tracking */ /* Internal functions for bucket use and lifecycle tracking */
apr_status_t serf_debug__record_read( 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);
void serf_debug__entered_loop( void serf_debug__entered_loop(
serf_bucket_alloc_t *allocator); serf_bucket_alloc_t *allocator);
void serf_debug__closed_conn( void serf_debug__closed_conn(
serf_bucket_alloc_t *allocator); serf_bucket_alloc_t *allocator);
void serf_debug__bucket_destroy( void serf_debug__bucket_destroy(
const serf_bucket_t *bucket); const serf_bucket_t *bucket);
void serf_debug__bucket_alloc_check( void serf_debug__bucket_alloc_check(
serf_bucket_alloc_t *allocator); serf_bucket_alloc_t *allocator);
/* Version info */ /* Version info */
#define SERF_MAJOR_VERSION 1 #define SERF_MAJOR_VERSION 2
#define SERF_MINOR_VERSION 3 #define SERF_MINOR_VERSION 0
#define SERF_PATCH_VERSION 3 #define SERF_PATCH_VERSION 0
/* Version number string */ /* Version number string */
#define SERF_VERSION_STRING APR_STRINGIFY(SERF_MAJOR_VERSION) "." \ #define SERF_VERSION_STRING APR_STRINGIFY(SERF_MAJOR_VERSION) "." \
APR_STRINGIFY(SERF_MINOR_VERSION) "." \ APR_STRINGIFY(SERF_MINOR_VERSION) "." \
APR_STRINGIFY(SERF_PATCH_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
 End of changes. 13 change blocks. 
5 lines changed or deleted 465 lines changed or added


 serf_bucket_types.h   serf_bucket_types.h 
skipping to change at line 88 skipping to change at line 88
serf_bucket_t *serf_bucket_response_create( 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))
#define SERF_HTTP_11 SERF_HTTP_VERSION(1, 1) #define SERF_HTTP_11 SERF_HTTP_VERSION(1, 1)
#define SERF_HTTP_10 SERF_HTTP_VERSION(1, 0) #define SERF_HTTP_10 SERF_HTTP_VERSION(1, 0)
#define SERF_HTTP_VERSION_MAJOR(shv) ((int)shv / 1000) #define SERF_HTTP_VERSION_MAJOR(shv) ((int)shv / 1000)
#define SERF_HTTP_VERSION_MINOR(shv) ((int)shv % 1000) #define SERF_HTTP_VERSION_MINOR(shv) ((int)shv % 1000)
typedef struct { typedef struct serf_status_line {
int version; int version;
int code; int code;
const char *reason; const char *reason;
} serf_status_line; } serf_status_line;
/** /**
* Return the Status-Line information, if available. This function * Return the Status-Line information, if available. This function
* works like other bucket read functions: it may return APR_EAGAIN or * works like other bucket read functions: it may return APR_EAGAIN or
* APR_EOF to signal the state of the bucket for reading. A return * APR_EOF to signal the state of the bucket for reading. A return
* value of APR_SUCCESS will always indicate that status line * value of APR_SUCCESS will always indicate that status line
skipping to change at line 471 skipping to change at line 471
extern const serf_bucket_type_t serf_bucket_type_limit; 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_bucket_t *serf_bucket_limit_create( serf_bucket_t *serf_bucket_limit_create(
serf_bucket_t *stream, serf_bucket_t *stream,
apr_uint64_t limit, apr_uint64_t limit,
serf_bucket_alloc_t *allocator); serf_bucket_alloc_t *allocator);
/* ==================================================================== */ /* ==================================================================== */
#define SERF_SSL_CERT_NOTYETVALID 1 #define SERF_SSL_CERT_NOTYETVALID 0x0001
#define SERF_SSL_CERT_EXPIRED 2 #define SERF_SSL_CERT_EXPIRED 0x0002
#define SERF_SSL_CERT_UNKNOWNCA 4 #define SERF_SSL_CERT_UNKNOWNCA 0x0004
#define SERF_SSL_CERT_SELF_SIGNED 8 #define SERF_SSL_CERT_SELF_SIGNED 0x0008
#define SERF_SSL_CERT_UNKNOWN_FAILURE 16 #define SERF_SSL_CERT_UNKNOWN_FAILURE 0x0010
#define SERF_SSL_CERT_REVOKED 32 #define SERF_SSL_CERT_REVOKED 0x0020
#define SERF_SSL_CERT_UNABLE_TO_GET_CRL 0x0040
#define SERF_SSL_CERT_INVALID_HOST 0x0080
#define SERF_SSL_OCSP_RESPONDER_TRYLATER 0x0100
#define SERF_SSL_OCSP_RESPONDER_ERROR 0x0200
#define SERF_SSL_OCSP_RESPONDER_UNKNOWN_FAILURE 0x0400
extern const serf_bucket_type_t serf_bucket_type_ssl_encrypt; extern const serf_bucket_type_t serf_bucket_type_ssl_encrypt;
#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 struct serf_ssl_certificate_t serf_ssl_certificate_t;
typedef apr_status_t (*serf_ssl_need_client_cert_t)( typedef apr_status_t (*serf_ssl_need_client_cert_t)(
void *data, void *data,
const char **cert_path); const char **cert_path);
typedef apr_status_t (*serf_ssl_need_cert_password_t)( typedef apr_status_t (*serf_ssl_need_cert_password_t)(
void *data, void *data,
const char *cert_path, const char *cert_path,
const char **password); const char **password);
/* Callback type for server certificate status info and OCSP responses.
Note that CERT can be NULL in case its called from the OCSP callback. */
typedef apr_status_t (*serf_ssl_need_server_cert_t)( typedef apr_status_t (*serf_ssl_need_server_cert_t)(
void *data, void *data,
int failures, int failures,
const serf_ssl_certificate_t *cert); const serf_ssl_certificate_t *cert);
typedef apr_status_t (*serf_ssl_server_cert_chain_cb_t)( typedef apr_status_t (*serf_ssl_server_cert_chain_cb_t)(
void *data, void *data,
int failures, int failures,
int error_depth, int error_depth,
const serf_ssl_certificate_t * const * certs, const serf_ssl_certificate_t * const * certs,
skipping to change at line 606 skipping to change at line 614
/** /**
* Adds the certificate @a cert to the list of trusted certificates in * Adds the certificate @a cert to the list of trusted certificates in
* @a ssl_ctx that will be used for verification. * @a ssl_ctx that will be used for verification.
* See also @a serf_ssl_load_cert_file. * See also @a serf_ssl_load_cert_file.
*/ */
apr_status_t serf_ssl_trust_cert( apr_status_t serf_ssl_trust_cert(
serf_ssl_context_t *ssl_ctx, serf_ssl_context_t *ssl_ctx,
serf_ssl_certificate_t *cert); serf_ssl_certificate_t *cert);
/** /**
* Load a CRL .pem file from @a file_path and enable CRL checking.
*/
apr_status_t serf_ssl_add_crl_from_file(serf_ssl_context_t *ssl_ctx,
const char *file_path,
apr_pool_t *pool);
/**
* Enable or disable CRL checking of all server certificates.
* @a enabled = 1 to enable CRL checking, 0 to disable CRL checking.
* Default = disabled.
*/
apr_status_t serf_ssl_check_crl(serf_ssl_context_t *ssl_ctx,
int enabled);
/**
* Enable or disable certificate status request (OCSP stapling) checking of
all
* server certificates.
* @a enabled = 1 to enable checking, 0 to disable checking.
* Default = disabled.
*/
apr_status_t
serf_ssl_check_cert_status_request(serf_ssl_context_t *ssl_ctx, int enabled
);
/**
* Enable or disable SSL compression on a SSL session. * Enable or disable SSL compression on a SSL session.
* @a enabled = 1 to enable compression, 0 to disable compression. * @a enabled = 1 to enable compression, 0 to disable compression.
* Default = disabled. * Default = disabled.
*/ */
apr_status_t serf_ssl_use_compression( apr_status_t serf_ssl_use_compression(
serf_ssl_context_t *ssl_ctx, serf_ssl_context_t *ssl_ctx,
int enabled); int enabled);
serf_bucket_t *serf_bucket_ssl_encrypt_create( serf_bucket_t *serf_bucket_ssl_encrypt_create(
serf_bucket_t *stream, serf_bucket_t *stream,
skipping to change at line 656 skipping to change at line 688
extern const serf_bucket_type_t serf_bucket_type_iovec; extern const serf_bucket_type_t serf_bucket_type_iovec;
#define SERF_BUCKET_IS_IOVEC(b) SERF_BUCKET_CHECK((b), iovec) #define SERF_BUCKET_IS_IOVEC(b) SERF_BUCKET_CHECK((b), iovec)
serf_bucket_t *serf_bucket_iovec_create( serf_bucket_t *serf_bucket_iovec_create(
struct iovec vecs[], struct iovec vecs[],
int len, int len,
serf_bucket_alloc_t *allocator); serf_bucket_alloc_t *allocator);
/* ==================================================================== */ /* ==================================================================== */
extern const serf_bucket_type_t serf_bucket_type_copy;
#define SERF_BUCKET_IS_COPY(b) SERF_BUCKET_CHECK((b), copy)
serf_bucket_t *serf_bucket_copy_create(
serf_bucket_t *wrapped,
apr_size_t min_size,
serf_bucket_alloc_t *allocator);
/* ==================================================================== */
/* ### do we need a PIPE bucket type? they are simple apr_file_t objects */ /* ### do we need a PIPE bucket type? they are simple apr_file_t objects */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* !SERF_BUCKET_TYPES_H */ #endif /* !SERF_BUCKET_TYPES_H */
 End of changes. 5 change blocks. 
7 lines changed or deleted 51 lines changed or added


 serf_bucket_util.h   serf_bucket_util.h 
skipping to change at line 99 skipping to change at line 99
/** /**
* Default implementation of the @see destroy functionality. * Default implementation of the @see destroy functionality.
* *
* This function will return the @a bucket, and the data member to its * This function will return the @a bucket, and the data member to its
* allocator. * allocator.
*/ */
void serf_default_destroy_and_data( void serf_default_destroy_and_data(
serf_bucket_t *bucket); serf_bucket_t *bucket);
/** /**
* Default implementation of the @see set_config functionality.
*
* This function will not do anything, it should be used in buckets
* that have no use for the shared config, and do not wrap other bucket(s).
*/
apr_status_t serf_default_ignore_config(serf_bucket_t *bucket,
serf_config_t *config);
/**
* Allocate @a size bytes of memory using @a allocator. * Allocate @a size bytes of memory using @a allocator.
* *
* Returns NULL of the requested memory size could not be allocated. * Returns NULL of the requested memory size could not be allocated.
*/ */
void *serf_bucket_mem_alloc( void *serf_bucket_mem_alloc(
serf_bucket_alloc_t *allocator, serf_bucket_alloc_t *allocator,
apr_size_t size); apr_size_t size);
/** /**
* Allocate @a size bytes of memory using @a allocator and set all of the * Allocate @a size bytes of memory using @a allocator and set all of the
skipping to change at line 218 skipping to change at line 227
apr_size_t *len); apr_size_t *len);
/** /**
* This structure is used as an intermediate data buffer for some "external " * This structure is used as an intermediate data buffer for some "external "
* source of data. It works as a scratch pad area for incoming data to be * source of data. It works as a scratch pad area for incoming data to be
* stored, and then returned as a ptr/len pair by the bucket read functions . * stored, and then returned as a ptr/len pair by the bucket read functions .
* *
* This structure should be initialized by calling @see serf_databuf_init. * This structure should be initialized by calling @see serf_databuf_init.
* Users should not bother to zero the structure beforehand. * Users should not bother to zero the structure beforehand.
*/ */
typedef struct { typedef struct serf_databuf_t {
/** The current data position within the buffer. */ /** The current data position within the buffer. */
const char *current; const char *current;
/** Amount of data remaining in the buffer. */ /** Amount of data remaining in the buffer. */
apr_size_t remaining; apr_size_t remaining;
/** Callback function. */ /** Callback function. */
serf_databuf_reader_t read; serf_databuf_reader_t read;
/** A baton to hold context-specific data. */ /** A baton to hold context-specific data. */
 End of changes. 2 change blocks. 
1 lines changed or deleted 10 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/