MCPcopy Create free account
hub / github.com/apache/httpd / ap_proxy_transfer_between_connections

Function ap_proxy_transfer_between_connections

modules/proxy/proxy_util.c:5234–5379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5232#define PROXY_TRANSFER_MAX_READS 10000
5233
5234PROXY_DECLARE(apr_status_t) ap_proxy_transfer_between_connections(
5235 request_rec *r,
5236 conn_rec *c_i,
5237 conn_rec *c_o,
5238 apr_bucket_brigade *bb_i,
5239 apr_bucket_brigade *bb_o,
5240 const char *name,
5241 int *sent,
5242 apr_off_t bsize,
5243 int flags)
5244{
5245 apr_status_t rv;
5246 int flush_each = 0;
5247 unsigned int num_reads = 0;
5248#ifdef DEBUGGING
5249 apr_off_t len;
5250#endif
5251
5252 /*
5253 * Compat: since FLUSH_EACH is default (and zero) for legacy reasons, we
5254 * pretend it's no FLUSH_AFTER nor YIELD_PENDING flags, the latter because
5255 * flushing would defeat the purpose of checking for pending data (hence
5256 * determine whether or not the output chain/stack is full for stopping).
5257 */
5258 if (!(flags & (AP_PROXY_TRANSFER_FLUSH_AFTER |
5259 AP_PROXY_TRANSFER_YIELD_PENDING))) {
5260 flush_each = 1;
5261 }
5262
5263 for (;;) {
5264 apr_brigade_cleanup(bb_i);
5265 rv = ap_get_brigade(c_i->input_filters, bb_i, AP_MODE_READBYTES,
5266 APR_NONBLOCK_READ, bsize);
5267 if (rv != APR_SUCCESS) {
5268 if (!APR_STATUS_IS_EAGAIN(rv) && !APR_STATUS_IS_EOF(rv)) {
5269 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(03308)
5270 "ap_proxy_transfer_between_connections: "
5271 "error on %s - ap_get_brigade",
5272 name);
5273 if (rv == APR_INCOMPLETE) {
5274 /* Don't return APR_INCOMPLETE, it'd mean "should yield"
5275 * for the caller, while it means "incomplete body" here
5276 * from ap_http_filter(), which is an error.
5277 */
5278 rv = APR_EGENERAL;
5279 }
5280 }
5281 break;
5282 }
5283
5284 if (c_o->aborted) {
5285 apr_brigade_cleanup(bb_i);
5286 flags &= ~AP_PROXY_TRANSFER_FLUSH_AFTER;
5287 rv = APR_EPIPE;
5288 break;
5289 }
5290 if (APR_BRIGADE_EMPTY(bb_i)) {
5291 break;

Callers 2

proxy_wstunnel_requestFunction · 0.85
proxy_tunnel_forwardFunction · 0.85

Calls 6

ap_get_brigadeFunction · 0.85
ap_pass_brigadeFunction · 0.85
ap_filter_should_yieldFunction · 0.85
ap_filter_output_pendingFunction · 0.85
ap_fflushFunction · 0.85

Tested by

no test coverage detected