static int http_create_request(request_rec *r) { if (!r->main && !r->prev) { ap_add_output_filter_handle(ap_byterange_filter_handle, NULL, r, r->connection); ap_add_output_filter_handle(ap_content_length_filter_handle, NULL, r, r->connection); ap_add_output_filter_handle(ap_http_header_filter_handle, NULL, r, r->connection); } return OK; }
static void filter_insert(request_rec *r) { mod_filter_chain *p; ap_filter_rec_t *filter; mod_filter_cfg *cfg = ap_get_module_config(r->per_dir_config, &filter_module); #ifndef NO_PROTOCOL int ranges = 1; mod_filter_ctx *ctx = apr_pcalloc(r->pool, sizeof(mod_filter_ctx)); ap_set_module_config(r->request_config, &filter_module, ctx); #endif for (p = cfg->chain; p; p = p->next) { filter = apr_hash_get(cfg->live_filters, p->fname, APR_HASH_KEY_STRING); if (filter == NULL) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "Unknown filter %s not added", p->fname); continue; } ap_add_output_filter_handle(filter, NULL, r, r->connection); #ifndef NO_PROTOCOL if (ranges && (filter->proto_flags & (AP_FILTER_PROTO_NO_BYTERANGE | AP_FILTER_PROTO_CHANGE_LENGTH))) { ctx->range = apr_table_get(r->headers_in, "Range"); apr_table_unset(r->headers_in, "Range"); ranges = 0; } #endif } return; }
static int cdn_request_handler(request_rec *r) { cdn_conf *cfg = ap_get_module_config(r->per_dir_config, &cdn_module); /* * first, do originification, which only touches output headers, if * the object's request URL matches one of the CDNActAsOrigin * regexes */ if(cfg->originify) { int i, verify_auth; act_as_origin_t *orig = (act_as_origin_t *)cfg->originify->elts; for(i = 0; i < cfg->originify->nelts; ++i) { if(!ap_regexec(&(orig[i].regex), r->uri, 0, 0, 0)) { ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, "cdn_request_handler: adding CDN origin headers for %s", r->uri); verify_auth = add_origin_headers(cfg, r, &orig[i]); if(verify_auth && verify_auth_token(cfg, r) != OK) return HTTP_UNAUTHORIZED; break; } } } /* decide whether to install cdn_html_filter */ if(cfg->content_types && cfg->links && cfg->map) { ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server, "cdn_request_handler: adding cdn_html_filter for %s", r->uri); ap_add_output_filter_handle(cdn_html_filter_handle, NULL, r, r->connection); } return DECLINED; }
static int cleanup_handler(request_rec *r){ ap_add_output_filter_handle(log_output_start_handle, NULL, r, r->connection); //Register Cleanup Handler apr_pool_cleanup_register(r->pool, (void*)r, log_connection_close,apr_pool_cleanup_null) ; return DECLINED; }
static int lua_ap_add_output_filter(lua_State *L) { request_rec *r = CHECK_REQUEST_OBJECT(1); const char* filterName = luaL_checkstring(L, 2); ap_filter_rec_t *filter = ap_get_output_filter_handle(filterName); if (filter) { ap_add_output_filter_handle(filter, NULL, r, r->connection); lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); } return 1; }
static void filter_insert(request_rec *r) { mod_filter_chain *p; ap_filter_rec_t *filter; mod_filter_cfg *cfg = ap_get_module_config(r->per_dir_config, &filter_module); #ifndef NO_PROTOCOL int ranges = 1; mod_filter_ctx *ctx = apr_pcalloc(r->pool, sizeof(mod_filter_ctx)); ap_set_module_config(r->request_config, &filter_module, ctx); #endif /** IG: Now that we've merged to the final config, go one last time * through the chain, and prune out the NULL filters */ for (p = cfg->chain; p; p = p->next) { if (p->fname == NULL) cfg->chain = p->next; } for (p = cfg->chain; p; p = p->next) { filter = apr_hash_get(cfg->live_filters, p->fname, APR_HASH_KEY_STRING); if (filter == NULL) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01380) "Unknown filter %s not added", p->fname); continue; } ap_add_output_filter_handle(filter, NULL, r, r->connection); #ifndef NO_PROTOCOL if (ranges && (filter->proto_flags & (AP_FILTER_PROTO_NO_BYTERANGE | AP_FILTER_PROTO_CHANGE_LENGTH))) { ctx->range = apr_table_get(r->headers_in, "Range"); apr_table_unset(r->headers_in, "Range"); ranges = 0; } #endif } }