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

Function uwsgi_handler

modules/proxy/mod_proxy_uwsgi.c:500–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500static int uwsgi_handler(request_rec *r, proxy_worker * worker,
501 proxy_server_conf * conf, char *url,
502 const char *proxyname, apr_port_t proxyport)
503{
504 int status;
505 proxy_conn_rec *backend = NULL;
506 apr_pool_t *p = r->pool;
507 char server_portstr[32];
508 char *u_path_info;
509 apr_uri_t *uri;
510
511 if (ap_cstr_casecmpn(url, UWSGI_SCHEME "://", sizeof(UWSGI_SCHEME) + 2)) {
512 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "declining URL %s", url);
513 return DECLINED;
514 }
515
516 uri = apr_palloc(r->pool, sizeof(*uri));
517
518 /* ADD PATH_INFO (unescaped) */
519 u_path_info = ap_strchr(url + sizeof(UWSGI_SCHEME) + 2, '/');
520 if (!u_path_info) {
521 u_path_info = apr_pstrdup(r->pool, "/");
522 }
523 else if (ap_unescape_url(u_path_info) != OK) {
524 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10100)
525 "unable to decode uwsgi uri: %s", url);
526 return HTTP_INTERNAL_SERVER_ERROR;
527 }
528 else {
529 /* Remove duplicate slashes at the beginning of PATH_INFO */
530 while (u_path_info[1] == '/') {
531 u_path_info++;
532 }
533 }
534 apr_table_add(r->subprocess_env, "PATH_INFO", u_path_info);
535
536 /* Create space for state information */
537 status = ap_proxy_acquire_connection(UWSGI_SCHEME, &backend, worker,
538 r->server);
539 if (status != OK) {
540 goto cleanup;
541 }
542 backend->is_ssl = 0;
543
544 /* Step One: Determine Who To Connect To */
545 status = ap_proxy_determine_connection(p, r, conf, worker, backend,
546 uri, &url, proxyname, proxyport,
547 server_portstr,
548 sizeof(server_portstr));
549 if (status != OK) {
550 goto cleanup;
551 }
552
553
554 /* Step Two: Make the Connection */
555 if (ap_proxy_connect_backend(UWSGI_SCHEME, backend, worker, r->server)) {
556 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10101)
557 "failed to make connection to backend: %s:%u",

Callers

nothing calls this directly

Calls 11

ap_cstr_casecmpnFunction · 0.85
ap_strchrFunction · 0.85
ap_unescape_urlFunction · 0.85
ap_proxy_connect_backendFunction · 0.85
ap_setup_client_blockFunction · 0.85
uwsgi_send_headersFunction · 0.85
uwsgi_send_bodyFunction · 0.85

Tested by

no test coverage detected