/* read available data (in blocks of CONN_BLKSZ) from c_i and copy to c_o */
static int proxy_connect_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
- apr_bucket_brigade *bb, char *name)
+ apr_bucket_brigade *bb_i,
+ apr_bucket_brigade *bb_o, char *name)
{
int rv;
#ifdef DEBUGGING
#endif
do {
- apr_brigade_cleanup(bb);
- rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
+ apr_brigade_cleanup(bb_i);
+ rv = ap_get_brigade(c_i->input_filters, bb_i, AP_MODE_READBYTES,
APR_NONBLOCK_READ, CONN_BLKSZ);
if (rv == APR_SUCCESS) {
if (c_o->aborted)
return APR_EPIPE;
- if (APR_BRIGADE_EMPTY(bb))
+ if (APR_BRIGADE_EMPTY(bb_i))
break;
#ifdef DEBUGGING
len = -1;
- apr_brigade_length(bb, 0, &len);
+ apr_brigade_length(bb_i, 0, &len);
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01016)
"read %" APR_OFF_T_FMT
" bytes from %s", len, name);
#endif
- rv = ap_pass_brigade(c_o->output_filters, bb);
+ ap_proxy_buckets_lifetime_transform(r, bb_i, bb_o);
+ rv = ap_pass_brigade(c_o->output_filters, bb_o);
if (rv == APR_SUCCESS) {
- ap_fflush(c_o->output_filters, bb);
+ ap_fflush(c_o->output_filters, bb_o);
}
else {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01017)
conn_rec *backconn;
int done = 0;
- apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
+ apr_bucket_brigade *bb_front = apr_brigade_create(p, c->bucket_alloc);
+ apr_bucket_brigade *bb_back;
apr_status_t rv;
apr_size_t nbytes;
char buffer[HUGE_STRING_LEN];
apr_table_setn(r->notes, "proxy-source-port", apr_psprintf(r->pool, "%hu",
backconn->local_addr->port));
+
+ bb_back = apr_brigade_create(p, backconn->bucket_alloc);
+
/* If we are connecting through a remote proxy, we need to pass
* the CONNECT request on to it.
*/
*/
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
"sending the CONNECT request to the remote proxy");
- ap_fprintf(backconn->output_filters, bb,
+ ap_fprintf(backconn->output_filters, bb_back,
"CONNECT %s HTTP/1.0" CRLF, r->uri);
- ap_fprintf(backconn->output_filters, bb,
+ ap_fprintf(backconn->output_filters, bb_back,
"Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
- ap_fflush(backconn->output_filters, bb);
+ ap_fflush(backconn->output_filters, bb_back);
}
else {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "Returning 200 OK");
nbytes = apr_snprintf(buffer, sizeof(buffer),
"HTTP/1.0 200 Connection Established" CRLF);
ap_xlate_proto_to_ascii(buffer, nbytes);
- ap_fwrite(c->output_filters, bb, buffer, nbytes);
+ ap_fwrite(c->output_filters, bb_front, buffer, nbytes);
nbytes = apr_snprintf(buffer, sizeof(buffer),
"Proxy-agent: %s" CRLF CRLF,
ap_get_server_banner());
ap_xlate_proto_to_ascii(buffer, nbytes);
- ap_fwrite(c->output_filters, bb, buffer, nbytes);
- ap_fflush(c->output_filters, bb);
+ ap_fwrite(c->output_filters, bb_front, buffer, nbytes);
+ ap_fflush(c->output_filters, bb_front);
#if 0
/* This is safer code, but it doesn't work yet. I'm leaving it
* here so that I can fix it later.
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01025)
"sock was readable");
#endif
- done |= proxy_connect_transfer(r, backconn, c, bb,
- "sock") != APR_SUCCESS;
+ done |= proxy_connect_transfer(r, backconn, c, bb_back,
+ bb_front, "sock")
+ != APR_SUCCESS;
}
else if (pollevent & APR_POLLERR) {
ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(01026)
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01027)
"client was readable");
#endif
- done |= proxy_connect_transfer(r, c, backconn, bb,
- "client") != APR_SUCCESS;
+ done |= proxy_connect_transfer(r, c, backconn, bb_front,
+ bb_back, "client")
+ != APR_SUCCESS;
}
else if (pollevent & APR_POLLERR) {
ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02827)