/*
 * Internal redirect / subrequest handler, working on request_status hook
 */
static int scgi_request_status(int *status, request_rec *r)
{
    scgi_request_config *req_conf;

    if (   (*status == OK)
        && (req_conf = ap_get_module_config(r->request_config,
                                            &proxy_scgi_module))) {
        switch (req_conf->type) {
        case scgi_internal_redirect:
            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                          "proxy: " PROXY_FUNCTION ": Internal redirect to %s",
                          req_conf->location);

            r->status_line = NULL;
            if (r->method_number != M_GET) {
                /* keep HEAD, which is passed around as M_GET, too */
                r->method = "GET";
                r->method_number = M_GET;
            }
            apr_table_unset(r->headers_in, "Content-Length");
            ap_internal_redirect_handler(req_conf->location, r);
            return OK;
            /* break; */

        case scgi_sendfile:
            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                          "proxy: " PROXY_FUNCTION ": File subrequest to %s",
                          req_conf->location);
            do {
                request_rec *rr;

                rr = ap_sub_req_lookup_file(req_conf->location, r,
                                            r->output_filters);
                if (rr->status == HTTP_OK && rr->finfo.filetype != 0) {
                    /*
                     * We don't touch Content-Length here. It might be
                     * borked (there's plenty of room for a race condition).
                     * Either the backend sets it or it's gonna be chunked.
                     */
                    ap_run_sub_req(rr);
                }
                else {
                    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                                  "Subrequest to file '%s' not possible. "
                                  "(rr->status=%d, rr->finfo.filetype=%d)",
                                  req_conf->location, rr->status,
                                  rr->finfo.filetype);
                    *status = HTTP_INTERNAL_SERVER_ERROR;
                    return *status;
                }
            } while(0);

            return OK;
            /* break; */
        }
    }

    return DECLINED;
}
Ejemplo n.º 2
0
CStr qEnvApache::GetMimeType(const char *ext)
{
	if (!ext)
		return 0;

	CStr type;
	request_rec *rr;

#ifdef APACHE2
	rr = ap_sub_req_lookup_file(ext, myReq, NULL);
#else
	rr = ap_sub_req_lookup_file(ext, myReq);
#endif

	type = rr->content_type;
	ap_destroy_sub_req(rr);

	return type;
}
Ejemplo n.º 3
0
static int papi_send_file (request_rec *r, const char *filename)
{	
	request_rec *rs = ap_sub_req_lookup_file (filename, r, NULL);
	ap_set_content_type (r, rs->content_type);
	int err = ap_run_sub_req (rs);
	if (err != OK)
		APACHE_LOG (APLOG_ERR, "Cookie_Handler: Exception handling %s (%d)",
					   filename, err);
	ap_destroy_sub_req (rs);
	return err;
}
Ejemplo n.º 4
0
static int papi_send_file_with_cookies (request_rec *r, const char *filename, const char *lcook)
{
	
	request_rec *rs = ap_sub_req_lookup_file (filename, r, NULL);
	apr_table_set (r->err_headers_out, "Set-cookie", lcook);
	ap_set_content_type (r, rs->content_type);
	int err = ap_run_sub_req (rs);
	if (err != OK)
		APACHE_LOG (APLOG_ERR, "Cookie_Handler: Exception handling %s", filename);
	ap_destroy_sub_req (rs);
	return err;
}	
Ejemplo n.º 5
0
static char* zipread_getcontenttype(request_rec *r, const char *pi)
{
    request_rec *newRequest;
    char *pc = apr_pstrdup(r->pool, pi);
    char *p;

    if ((p = ap_strrchr(pc, '/')))
	p++;
    else
	p = pc;

    newRequest = ap_sub_req_lookup_file(p, r, NULL);

    // ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "mod_zipread subreq mime: %s", newRequest->content_type);

    if (newRequest->content_type)
	return (char*)newRequest->content_type;

    return "text/plain";
}