* input filtering modes
*/
typedef enum {
- /** The filter should return at most *readbytes data. */
+ /** The filter should return at most readbytes data. */
AP_MODE_READBYTES,
/** The filter should return at most one line of CRLF data.
* (If a potential line is too long or no CRLF is found, the
*/
typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b);
typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, apr_bucket_brigade *b,
- ap_input_mode_t mode, apr_read_type_e block, apr_off_t *readbytes);
+ ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes);
typedef union ap_filter_func {
ap_out_filter_func out_func;
apr_bucket_brigade *bucket,
ap_input_mode_t mode,
apr_read_type_e block,
- apr_off_t *readbytes);
+ apr_off_t readbytes);
/**
* Pass the current bucket brigade down to the next filter on the filter
apr_bucket_brigade *bb;
apr_bucket *b;
apr_status_t rv;
- apr_off_t zero = 0;
EchoConfig *pConfig = ap_get_module_config(c->base_server->module_config,
&echo_module);
for ( ; ; ) {
/* Get a single line of input from the client */
if ((rv = ap_get_brigade(c->input_filters, bb, AP_MODE_GETLINE,
- APR_BLOCK_READ, &zero) != APR_SUCCESS ||
+ APR_BLOCK_READ, 0) != APR_SUCCESS ||
APR_BRIGADE_EMPTY(bb))) {
apr_brigade_destroy(bb);
break;
apr_bucket_brigade *pbbOut,
ap_input_mode_t eMode,
apr_read_type_e eBlock,
- apr_off_t *nBytes)
+ apr_off_t nBytes)
{
request_rec *r = f->r;
CaseFilterInContext *pCtx;
static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_status_t rv;
charset_req_t *reqinfo = ap_get_module_config(f->r->request_config,
#if 0
static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_status_t rv;
apr_bucket *b;
*/
apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_bucket *e;
http_ctx_t *ctx = f->ctx;
apr_status_t rv;
+ apr_off_t totalread;
/* just get out of the way of things we don't want. */
if (mode != AP_MODE_READBYTES && mode != AP_MODE_GETLINE) {
/* Ensure that the caller can not go over our boundary point. */
if (ctx->state == BODY_LENGTH || ctx->state == BODY_CHUNK) {
- if (ctx->remaining < *readbytes) {
- *readbytes = ctx->remaining;
+ if (ctx->remaining < readbytes) {
+ readbytes = ctx->remaining;
}
- AP_DEBUG_ASSERT(*readbytes > 0); /* shouldn't be in getline mode */
+ AP_DEBUG_ASSERT(readbytes > 0);
}
rv = ap_get_brigade(f->next, b, mode, block, readbytes);
return rv;
}
+ /* How many bytes did we just read? */
+ apr_brigade_length(b, 0, &totalread);
+
+ /* If this happens, we have a bucket of unknown length. Die because
+ * it means our assumptions have changed. */
+ AP_DEBUG_ASSERT(totalread > 0);
+
if (ctx->state != BODY_NONE) {
- ctx->remaining -= *readbytes;
+ ctx->remaining -= totalread;
}
/* We have a limit in effect. */
/* FIXME: Note that we might get slightly confused on chunked inputs
* as we'd need to compensate for the chunk lengths which may not
* really count. This seems to be up for interpretation. */
- ctx->limit_used += *readbytes;
+ ctx->limit_used += totalread;
if (ctx->limit < ctx->limit_used) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, f->r,
"Read content-length of %" APR_OFF_T_FMT
/* read until we get a non-empty brigade */
while (APR_BRIGADE_EMPTY(bb)) {
- apr_off_t len_read = bufsiz;
if (ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
- APR_BLOCK_READ, &len_read) != APR_SUCCESS) {
+ APR_BLOCK_READ, bufsiz) != APR_SUCCESS) {
/* if we actually fail here, we want to just return and
* stop trying to read data from the client.
*/
### allow us to defer creation of the brigade to when we actually
### need to send a FLUSH. */
apr_bucket_brigade *bb = apr_brigade_create(r->pool);
- apr_off_t zero = 0;
/* Flush the filter contents if:
*
/* ### is zero correct? that means "read one line" */
if (!r->connection->keepalive ||
ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
- APR_NONBLOCK_READ, &zero) != APR_SUCCESS) {
+ APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
apr_bucket *e = apr_bucket_flush_create();
/* We just send directly to the connection based filters. At
*/
apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes);
+ apr_off_t readbytes);
char *ap_response_code_string(request_rec *r, int error_index);
int i = 0, j, len, rc;
int one = 1;
char *size = NULL;
- apr_off_t readbytes = -1;
apr_socket_t *origin_sock;
/* stuff for PASV mode */
"proxy: FTP: start body send");
/* read the body, pass it to the output filters */
- while (ap_get_brigade(remote->input_filters, bb, AP_MODE_READBYTES,
- APR_BLOCK_READ, &readbytes) == APR_SUCCESS) {
+ while (ap_get_brigade(remote->input_filters, bb, AP_MODE_EXHAUSTIVE,
+ APR_BLOCK_READ, 0) == APR_SUCCESS) {
if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
ap_pass_brigade(r->output_filters, bb);
break;
*/
if ( (conf->error_override ==0) || r->status < 400 ) {
/* read the body, pass it to the output filters */
- apr_off_t readbytes;
apr_bucket *e;
- readbytes = AP_IOBUFSIZE;
while (ap_get_brigade(rp->input_filters,
bb,
AP_MODE_READBYTES,
APR_BLOCK_READ,
- &readbytes) == APR_SUCCESS) {
+ AP_IOBUFSIZE) == APR_SUCCESS) {
#if DEBUGGING
+ {
+ apr_off_t readbytes;
+ apr_brigade_length(bb, 0, &readbytes);
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
r->server, "proxy (PID %d): readbytes: %#x",
getpid(), readbytes);
+ }
#endif
if (APR_BRIGADE_EMPTY(bb)) {
break;
break;
}
apr_brigade_cleanup(bb);
- readbytes = AP_IOBUFSIZE;
}
}
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
/* loop through each brigade */
while (!found) {
- apr_off_t zero = 0;
/* get brigade from network one line at a time */
if (APR_SUCCESS != (rv = ap_get_brigade(c->input_filters, bb,
AP_MODE_GETLINE,
APR_BLOCK_READ,
- &zero /* readline */))) {
+ 0))) {
return rv;
}
/* loop through each bucket */
{
BIO_bucket_in_t *inbio = BIO_bucket_in_ptr(bio);
int len = 0;
- apr_off_t readbytes = inl;
/* XXX: flush here only required for SSLv2;
* OpenSSL calls BIO_flush() at the appropriate times for
if ((len <= inl) || inbio->mode == AP_MODE_GETLINE) {
return len;
}
+ inl -= len;
}
while (1) {
* GETLINE.
*/
inbio->rc = ap_get_brigade(inbio->f->next, inbio->bb,
- AP_MODE_READBYTES, inbio->block, &readbytes);
+ AP_MODE_READBYTES, inbio->block,
+ inl);
if ((inbio->rc != APR_SUCCESS) || APR_BRIGADE_EMPTY(inbio->bb))
{
apr_bucket_brigade *bb,
ap_input_mode_t mode,
apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_status_t status;
ssl_io_input_ctx_t *ctx = f->ctx;
apr_size_t len = sizeof(ctx->buffer);
- apr_off_t bytes = *readbytes;
int is_init = (mode == AP_MODE_INIT);
/* XXX: we don't currently support anything other than these modes. */
if (ctx->inbio.mode == AP_MODE_READBYTES ||
ctx->inbio.mode == AP_MODE_SPECULATIVE) {
- /* Protected from truncation, bytes < MAX_SIZE_T */
- if (bytes < len) {
- len = (apr_size_t)bytes;
+ /* Protected from truncation, readbytes < MAX_SIZE_T
+ * FIXME: No, it's *not* protected. -- jre */
+ if (readbytes < len) {
+ len = (apr_size_t)readbytes;
}
status = ssl_io_input_read(ctx, ctx->buffer, &len);
}
APR_BRIGADE_INSERT_TAIL(bb, bucket);
}
- *readbytes = len;
-
return APR_SUCCESS;
}
static int net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
int keptalive = f->c->keepalive == 1;
apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode, apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_bucket *e;
apr_status_t rv;
/* Force a recompute of the length and force a read-all */
apr_brigade_length(ctx->b, 1, &total);
APR_BRIGADE_CONCAT(b, ctx->b);
- *readbytes = total;
/* We have read until the brigade was empty, so we know that we
* must be EOS. */
e = apr_bucket_eos_create();
apr_bucket *e;
apr_bucket_brigade *newbb;
- AP_DEBUG_ASSERT(*readbytes > 0);
+ AP_DEBUG_ASSERT(readbytes > 0);
e = APR_BRIGADE_FIRST(ctx->b);
rv = apr_bucket_read(e, &str, &len, block);
if (APR_STATUS_IS_EAGAIN(rv)) {
- *readbytes = 0;
return APR_SUCCESS;
}
else if (rv != APR_SUCCESS) {
return rv;
}
- /* We can only return at most what the user asked for. */
- if (len < *readbytes) {
- *readbytes = len;
+ /* We can only return at most what we read. */
+ if (len < readbytes) {
+ readbytes = len;
}
- apr_brigade_partition(ctx->b, *readbytes, &e);
+ apr_brigade_partition(ctx->b, readbytes, &e);
/* Must do split before CONCAT */
newbb = apr_brigade_split(ctx->b, e);
APR_BRIGADE_CONCAT(ctx->b, newbb);
apr_brigade_length(b, 1, &total);
- *readbytes = total;
return APR_SUCCESS;
}
* empty). We do this by returning whatever we have read. This may
* or may not be bogus, but is consistent (for now) with EOF logic.
*/
- if (APR_STATUS_IS_EAGAIN(rv) || rv == APR_SUCCESS) {
- apr_off_t total;
-
- apr_brigade_length(b, 1, &total);
- *readbytes = total;
- }
- else {
- return rv;
+ if (APR_STATUS_IS_EAGAIN(rv)) {
+ rv = APR_SUCCESS;
}
- return APR_SUCCESS;
+ return rv;
}
/* Default filter. This filter should almost always be used. Its only job
&mpm_perchild_module);
char *foo;
apr_size_t len;
- apr_off_t zero = 0;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER",
r->connection->pool);
### reading large chunks of data or something?
*/
while (ap_get_brigade(r->input_filters, bb, AP_MODE_GETLINE,
- APR_NONBLOCK_READ, &zero) == APR_SUCCESS) {
+ APR_NONBLOCK_READ, 0) == APR_SUCCESS) {
apr_bucket *e;
APR_BRIGADE_FOREACH(e, bb) {
const char *str;
static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode,
apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_bucket *e;
apr_status_t rv;
&mpm_perchild_module);
char *foo;
apr_size_t len;
- apr_off_t zero = 0;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER",
r->connection->pool);
### reading large chunks of data or something?
*/
while (ap_get_brigade(r->input_filters, bb, AP_MODE_GETLINE,
- APR_NONBLOCK_READ, &zero) == APR_SUCCESS) {
+ APR_NONBLOCK_READ, 0) == APR_SUCCESS) {
apr_bucket *e;
APR_BRIGADE_FOREACH(e, bb) {
const char *str;
static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b,
ap_input_mode_t mode,
apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
apr_bucket *e;
apr_status_t rv;
b = apr_brigade_create(r->pool);
rv = ap_get_brigade(r->input_filters, b, AP_MODE_GETLINE,
- APR_BLOCK_READ, &bytes_read);
+ APR_BLOCK_READ, bytes_read);
if (rv != APR_SUCCESS) {
return rv;
/* We only care about the first byte. */
bytes_read = 1;
rv = ap_get_brigade(r->input_filters, b, AP_MODE_SPECULATIVE,
- APR_BLOCK_READ, &bytes_read);
+ APR_BLOCK_READ, bytes_read);
if (rv != APR_SUCCESS) {
return rv;
apr_bucket_brigade *bb,
ap_input_mode_t mode,
apr_read_type_e block,
- apr_off_t *readbytes)
+ apr_off_t readbytes)
{
if (next) {
return next->frec->filter_func.in_func(next, bb, mode, block,