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

Function pass_response

modules/proxy/mod_proxy_scgi.c:363–469  ·  view source on GitHub ↗

* Fetch response from backend and pass back to the front */

Source from the content-addressed store, hash-verified

361 * Fetch response from backend and pass back to the front
362 */
363static int pass_response(request_rec *r, proxy_conn_rec *conn)
364{
365 apr_bucket_brigade *bb;
366 apr_bucket *b;
367 const char *location;
368 scgi_config *conf;
369 socket_ex_data *sock_data;
370 int status;
371
372 sock_data = apr_palloc(r->pool, sizeof(*sock_data));
373 sock_data->sock = conn->sock;
374 sock_data->counter = &conn->worker->s->read;
375
376 bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
377 b = bucket_socket_ex_create(sock_data, r->connection->bucket_alloc);
378 APR_BRIGADE_INSERT_TAIL(bb, b);
379 b = apr_bucket_eos_create(r->connection->bucket_alloc);
380 APR_BRIGADE_INSERT_TAIL(bb, b);
381
382 status = ap_scan_script_header_err_brigade_ex(r, bb, NULL,
383 APLOG_MODULE_INDEX);
384 if (status != OK) {
385 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00860)
386 "error reading response headers from %s:%u",
387 conn->hostname, conn->port);
388 r->status_line = NULL;
389 apr_brigade_destroy(bb);
390 return status;
391 }
392
393 /* SCGI has its own body framing mechanism which we don't
394 * match against any provided Content-Length, so let the
395 * core determine C-L vs T-E based on what's actually sent.
396 */
397 if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
398 apr_table_unset(r->headers_out, "Content-Length");
399 apr_table_unset(r->headers_out, "Transfer-Encoding");
400
401 conf = ap_get_module_config(r->per_dir_config, &proxy_scgi_module);
402 if (conf->sendfile && conf->sendfile != scgi_sendfile_off) {
403 short err = 1;
404
405 location = apr_table_get(r->err_headers_out, conf->sendfile);
406 if (!location) {
407 err = 0;
408 location = apr_table_get(r->headers_out, conf->sendfile);
409 }
410 if (location) {
411 scgi_request_config *req_conf = apr_palloc(r->pool,
412 sizeof(*req_conf));
413 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00861)
414 "Found %s: %s - preparing subrequest.",
415 conf->sendfile, location);
416
417 if (err) {
418 apr_table_unset(r->err_headers_out, conf->sendfile);
419 }
420 else {

Callers 1

scgi_handlerFunction · 0.70

Calls 6

bucket_socket_ex_createFunction · 0.85
ap_get_module_configFunction · 0.85
ap_set_module_configFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_pass_brigadeFunction · 0.85

Tested by

no test coverage detected