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

Function include_cgi

modules/generators/mod_cgid.c:1643–1695  ·  view source on GitHub ↗

Handling include= for mod_include. */

Source from the content-addressed store, hash-verified

1641
1642/* Handling include= for mod_include. */
1643static apr_status_t include_cgi(include_ctx_t *ctx, ap_filter_t *f,
1644 apr_bucket_brigade *bb, char *s)
1645{
1646 request_rec *r = f->r;
1647 request_rec *rr = ap_sub_req_lookup_uri(s, r, f->next);
1648 int rr_status;
1649
1650 if (rr->status != HTTP_OK) {
1651 ap_destroy_sub_req(rr);
1652 return APR_EGENERAL;
1653 }
1654
1655 /* No hardwired path info or query allowed */
1656 if ((rr->path_info && rr->path_info[0]) || rr->args) {
1657 ap_destroy_sub_req(rr);
1658 return APR_EGENERAL;
1659 }
1660 if (rr->finfo.filetype != APR_REG) {
1661 ap_destroy_sub_req(rr);
1662 return APR_EGENERAL;
1663 }
1664
1665 /* Script gets parameters of the *document*, for back compatibility */
1666 rr->path_info = r->path_info; /* hard to get right; see mod_cgi.c */
1667 rr->args = r->args;
1668
1669 /* Force sub_req to be treated as a CGI request, even if ordinary
1670 * typing rules would have called it something else.
1671 */
1672 ap_set_content_type_ex(rr, CGI_MAGIC_TYPE, 1);
1673
1674 /* Run it. */
1675 rr_status = ap_run_sub_req(rr);
1676 if (ap_is_HTTP_REDIRECT(rr_status)) {
1677 const char *location = apr_table_get(rr->headers_out, "Location");
1678
1679 if (location) {
1680 char *buffer;
1681
1682 location = ap_escape_html(rr->pool, location);
1683 buffer = apr_pstrcat(ctx->pool, "<a href=\"", location, "\">",
1684 location, "</a>", NULL);
1685
1686 APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(buffer,
1687 strlen(buffer), ctx->pool,
1688 f->c->bucket_alloc));
1689 }
1690 }
1691
1692 ap_destroy_sub_req(rr);
1693
1694 return APR_SUCCESS;
1695}
1696
1697/* This is the special environment used for running the "exec cmd="
1698 * variety of SSI directives.

Callers

nothing calls this directly

Calls 4

ap_sub_req_lookup_uriFunction · 0.85
ap_destroy_sub_reqFunction · 0.85
ap_set_content_type_exFunction · 0.85
ap_run_sub_reqFunction · 0.85

Tested by

no test coverage detected