View | Details | Raw Unified | Return to bug 29744
Collapse All | Expand All

(-)httpd-2.2.6/modules/proxy/mod_proxy_connect.c.orig (+73 lines)
Lines 21-26 Link Here
21
#include "mod_proxy.h"
21
#include "mod_proxy.h"
22
#include "apr_poll.h"
22
#include "apr_poll.h"
23
23
24
#define CONN_BLKSZ AP_IOBUFSIZE
25
24
module AP_MODULE_DECLARE_DATA proxy_connect_module;
26
module AP_MODULE_DECLARE_DATA proxy_connect_module;
25
27
26
/*
28
/*
Lines 71-76 Link Here
71
    return OK;
73
    return OK;
72
}
74
}
73
75
76
/* read available data (in blocks of CONN_BLKSZ) from c_i and copy to c_o */
77
static int proxy_connect_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
78
                                apr_bucket_brigade *bb, char *name)
79
{
80
    int rv;
81
#ifdef DEBUGGING
82
    apr_off_t len;
83
#endif
84
85
    do {
86
      apr_brigade_cleanup(bb);
87
      rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
88
                          APR_NONBLOCK_READ, CONN_BLKSZ);
89
      if (rv == APR_SUCCESS) {
90
          if (APR_BRIGADE_EMPTY(bb))
91
              break;
92
#ifdef DEBUGGING
93
          len = -1;
94
          apr_brigade_length(bb, 0, &len);
95
          ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
96
                        "proxy: CONNECT: read %" APR_OFF_T_FMT
97
                        " bytes from %s", len, name);
98
#endif
99
          rv = ap_pass_brigade(c_o->output_filters, bb);
100
          if (rv == APR_SUCCESS) {
101
              ap_fflush(c_o->output_filters, bb);
102
          } else {
103
              ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
104
                            "proxy: CONNECT: error on %s - ap_pass_brigade",
105
                            name);
106
          }
107
      } else if (!APR_STATUS_IS_EAGAIN(rv)) {
108
          ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
109
                        "proxy: CONNECT: error on %s - ap_get_brigade",
110
                        name);
111
      }
112
    } while (rv == APR_SUCCESS);
113
114
    if (APR_STATUS_IS_EAGAIN(rv)) {
115
      rv = APR_SUCCESS;
116
    }
117
    return rv;
118
}
119
74
/* CONNECT handler */
120
/* CONNECT handler */
75
static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
121
static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
76
                                 proxy_server_conf *conf,
122
                                 proxy_server_conf *conf,
Lines 79-84 Link Here
79
{
125
{
80
    apr_pool_t *p = r->pool;
126
    apr_pool_t *p = r->pool;
81
    apr_socket_t *sock;
127
    apr_socket_t *sock;
128
    conn_rec *c = r->connection;
129
    conn_rec *backconn;
130
131
    apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
82
    apr_status_t err, rv;
132
    apr_status_t err, rv;
83
    apr_size_t i, o, nbytes;
133
    apr_size_t i, o, nbytes;
84
    char buffer[HUGE_STRING_LEN];
134
    char buffer[HUGE_STRING_LEN];
Lines 205-210 Link Here
205
        }
255
        }
206
    }
256
    }
207
257
258
    /* setup polling for connection */
259
    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
260
                "proxy: CONNECT: setting up poll()");
261
262
    if ((rv = apr_pollset_create(&pollset, 2, r->pool, 0)) != APR_SUCCESS) {
263
      apr_socket_close(sock);
264
        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
265
            "proxy: CONNECT: error apr_pollset_create()");
266
        return HTTP_INTERNAL_SERVER_ERROR;
267
    }
268
269
    /* Add client side to the poll */
270
    pollfd.p = r->pool;
271
    pollfd.desc_type = APR_POLL_SOCKET;
272
    pollfd.reqevents = APR_POLLIN;
273
    pollfd.desc.s = client_socket;
274
    pollfd.client_data = NULL;
275
    apr_pollset_add(pollset, &pollfd);
276
277
    /* Add the server side to the poll */
278
    pollfd.desc.s = sock;
279
    apr_pollset_add(pollset, &pollfd);
280
208
    /*
281
    /*
209
     * Step Three: Send the Request
282
     * Step Three: Send the Request
210
     *
283
     *

Return to bug 29744