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

Function scgi_handler

modules/proxy/mod_proxy_scgi.c:536–592  ·  view source on GitHub ↗

* This handles scgi:(dest) URLs */

Source from the content-addressed store, hash-verified

534 * This handles scgi:(dest) URLs
535 */
536static int scgi_handler(request_rec *r, proxy_worker *worker,
537 proxy_server_conf *conf, char *url,
538 const char *proxyname, apr_port_t proxyport)
539{
540 int status;
541 proxy_conn_rec *backend = NULL;
542 apr_pool_t *p = r->pool;
543 apr_uri_t *uri;
544 char dummy;
545
546 if (ap_cstr_casecmpn(url, SCHEME "://", sizeof(SCHEME) + 2)) {
547 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00865)
548 "declining URL %s", url);
549 return DECLINED;
550 }
551
552 /* Create space for state information */
553 status = ap_proxy_acquire_connection(PROXY_FUNCTION, &backend, worker,
554 r->server);
555 if (status != OK) {
556 goto cleanup;
557 }
558 backend->is_ssl = 0;
559
560 /* Step One: Determine Who To Connect To */
561 uri = apr_palloc(p, sizeof(*uri));
562 status = ap_proxy_determine_connection(p, r, conf, worker, backend,
563 uri, &url, proxyname, proxyport,
564 &dummy, 1);
565 if (status != OK) {
566 goto cleanup;
567 }
568
569 /* Step Two: Make the Connection */
570 if (ap_proxy_connect_backend(PROXY_FUNCTION, backend, worker, r->server)) {
571 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00866)
572 "failed to make connection to backend: %s:%u",
573 backend->hostname, backend->port);
574 status = HTTP_SERVICE_UNAVAILABLE;
575 goto cleanup;
576 }
577
578 /* Step Three: Process the Request */
579 if ( ((status = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK)
580 || ((status = send_headers(r, backend)) != OK)
581 || ((status = send_request_body(r, backend)) != OK)
582 || ((status = pass_response(r, backend)) != OK)) {
583 goto cleanup;
584 }
585
586cleanup:
587 if (backend) {
588 backend->close = 1; /* always close the socket */
589 ap_proxy_release_connection(PROXY_FUNCTION, backend, r->server);
590 }
591 return status;
592}
593

Callers

nothing calls this directly

Calls 9

ap_cstr_casecmpnFunction · 0.85
ap_proxy_connect_backendFunction · 0.85
ap_setup_client_blockFunction · 0.85
send_headersFunction · 0.85
send_request_bodyFunction · 0.85
pass_responseFunction · 0.70

Tested by

no test coverage detected