static am_status_t set_request_body(am_request_t *rq) { const char *thisfunc = "set_request_body():"; request_rec *r = (request_rec *) (rq != NULL ? rq->ctx : NULL); am_status_t status = AM_EINVAL; if (r == NULL || rq == NULL) { return status; } apr_table_unset(r->notes, amagent_post_filter_name); if (ISVALID(rq->post_data) && rq->post_data_sz > 0) { size_t data_sz = rq->post_data_sz; char *encoded = base64_encode(rq->post_data, &data_sz); if (encoded != NULL) { apr_table_set(r->notes, amagent_post_filter_name, encoded); am_log_debug(rq->instance_id, "%s preserved %d bytes", thisfunc, rq->post_data_sz); /* restore the content length so that we have a * match with a re-played data in the agent filter */ r->clength = rq->post_data_sz; apr_table_set(r->headers_in, "Content-Length", apr_psprintf(r->pool, "%ld", rq->post_data_sz)); free(encoded); } } return AM_SUCCESS; }
END_TEST void core_setup(void) { const unsigned int kIdx = 0; const unsigned int kEls = kIdx + 1; cas_cfg *cfg = NULL; cas_dir_cfg *d_cfg = NULL; apr_uri_t login; request = (request_rec *) malloc(sizeof(request_rec)); apr_pool_create(&pool, NULL); request->pool = pool; /* set up the request */ request->headers_in = apr_table_make(request->pool, 0); request->headers_out = apr_table_make(request->pool, 0); request->err_headers_out = apr_table_make(request->pool, 0); apr_table_set(request->headers_in, "Host", "foo.example.com"); apr_table_set(request->headers_in, "CAS_foo", "foo-value"); apr_table_set(request->headers_in, "Cookie", "foo=bar; " CAS_DEFAULT_COOKIE "=0123456789abcdef; baz=zot"); request->server = apr_pcalloc(request->pool, sizeof(struct server_rec)); request->connection = apr_pcalloc(request->pool, sizeof(struct conn_rec)); request->connection->local_addr = apr_pcalloc(request->pool, sizeof(apr_sockaddr_t)); apr_pool_userdata_set("https", "scheme", NULL, request->pool); request->server->server_hostname = "foo.example.com"; request->connection->local_addr->port = 80; request->unparsed_uri = "/foo?bar=baz&zot=qux"; request->uri = "/foo"; request->args = "bar=baz&zot=qux"; apr_uri_parse(request->pool, "http://foo.example.com/foo?bar=baz&zot=qux", &request->parsed_uri); /* set up the per server, and per directory configs */ auth_cas_module.module_index = kIdx; cfg = cas_create_server_config(request->pool, request->server); cfg->CASDebug = TRUE; memset(&login, 0, sizeof(login)); login.scheme = "https"; login.hostname = "login.example.com"; login.path = "/cas/login"; login.port = 0; memcpy(&cfg->CASLoginURL, &login, sizeof(apr_uri_t)); d_cfg = cas_create_dir_config(request->pool, NULL); request->request_config = apr_pcalloc(request->pool, sizeof(ap_conf_vector_t *)*kEls); request->server->module_config = apr_pcalloc(request->pool, sizeof(ap_conf_vector_t *)*kEls); request->per_dir_config = apr_pcalloc(request->pool, sizeof(ap_conf_vector_t *)*kEls); ap_set_module_config(request->server->module_config, &auth_cas_module, cfg); ap_set_module_config(request->per_dir_config, &auth_cas_module, d_cfg); }
/* Respond to a "create-txn" POST request. * * Syntax: ( create-txn ) */ dav_error * dav_svn__post_create_txn(const dav_resource *resource, svn_skel_t *request_skel, ap_filter_t *output) { const char *txn_name; const char *vtxn_name; dav_error *derr; request_rec *r = resource->info->r; /* Create a Subversion repository transaction based on HEAD. */ if ((derr = dav_svn__create_txn(resource->info->repos, &txn_name, NULL, resource->pool))) return derr; /* Build a "201 Created" response with header that tells the client our new transaction's name. */ vtxn_name = apr_table_get(r->headers_in, SVN_DAV_VTXN_NAME_HEADER); if (vtxn_name && vtxn_name[0]) { /* If the client supplied a vtxn name then store a mapping from the client name to the FS transaction name in the activity database. */ if ((derr = dav_svn__store_activity(resource->info->repos, vtxn_name, txn_name))) return derr; apr_table_set(r->headers_out, SVN_DAV_VTXN_NAME_HEADER, vtxn_name); } else apr_table_set(r->headers_out, SVN_DAV_TXN_NAME_HEADER, txn_name); r->status = HTTP_CREATED; return NULL; }
static int change_remote_ip(request_rec *r) { const char *fwdvalue; char *val; rpaf_server_cfg *cfg = (rpaf_server_cfg *)ap_get_module_config(r->server->module_config, &rpaf_module); if (!cfg->enable) return DECLINED; if (cfg->remote_addr_env) { apr_table_set(r->subprocess_env, cfg->remote_addr_env, r->connection->remote_ip); } if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) { /* check if cfg->headername is set and if it is use that instead of X-Forwarded-For by default */ if (cfg->headername && (fwdvalue = apr_table_get(r->headers_in, cfg->headername))) { // } else if ((fwdvalue = apr_table_get(r->headers_in, "X-Forwarded-For"))) { // } else { return DECLINED; } if (fwdvalue) { rpaf_cleanup_rec *rcr = (rpaf_cleanup_rec *)apr_pcalloc(r->pool, sizeof(rpaf_cleanup_rec)); apr_array_header_t *arr = apr_array_make(r->pool, 0, sizeof(char*)); while (*fwdvalue && (val = ap_get_token(r->pool, &fwdvalue, 1))) { *(char **)apr_array_push(arr) = apr_pstrdup(r->pool, val); if (*fwdvalue != '\0') ++fwdvalue; } rcr->old_ip = r->connection->remote_ip; rcr->old_family = r->connection->remote_addr->sa.sin.sin_family; rcr->r = r; apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null); r->connection->remote_ip = apr_pstrdup(r->pool, extract_ip(arr, cfg->proxy_ips, cfg->recursive)); r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip); r->connection->remote_addr->sa.sin.sin_family = AF_INET; if (cfg->sethostname) { const char *hostvalue; if ((hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host"))) { /* 2.0 proxy frontend or 1.3 => 1.3.25 proxy frontend */ apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, hostvalue)); r->hostname = apr_pstrdup(r->pool, hostvalue); ap_update_vhost_from_headers(r); } else if ((hostvalue = apr_table_get(r->headers_in, "X-Host"))) { /* 1.3 proxy frontend with mod_proxy_add_forward */ apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, hostvalue)); r->hostname = apr_pstrdup(r->pool, hostvalue); ap_update_vhost_from_headers(r); } } } } return DECLINED; }
static void table_set(abts_case *tc, void *data) { const char *val; apr_table_set(t1, "setkey", "bar"); apr_table_set(t1, "setkey", "2ndtry"); val = apr_table_get(t1, "setkey"); ABTS_STR_EQUAL(tc, "2ndtry", val); }
static int pass_in_env(request_rec *r, RuntimeScanner *scanner) { if ((scanner->block && !scanner->learning) || scanner->drop) apr_table_set(r->subprocess_env, "defender_action", "block"); for (const auto &match : scanner->matchScores) { apr_table_set(r->subprocess_env, apr_psprintf(r->pool, "defender_%s", match.first.c_str()), apr_itoa(r->pool, match.second)); } return DECLINED; }
static SV *make_env(request_rec *r, psgi_dir_config *c) { dTHX; HV *env; AV *version; char *url_scheme, *script_name, *vpath, *path_info; SV *input, *errors; env = newHV(); ap_add_cgi_vars(r); ap_add_common_vars(r); /* fix SCRIPT_NAME & PATH_INFO */ if (c->location == NULL || strcmp(c->location, "/") == 0) { script_name = ""; } else { script_name = c->location; } vpath = apr_pstrcat(r->pool, apr_table_get(r->subprocess_env, "SCRIPT_NAME"), apr_table_get(r->subprocess_env, "PATH_INFO"), NULL); path_info = &vpath[strlen(script_name)]; apr_table_set(r->subprocess_env, "PATH_INFO", path_info); apr_table_set(r->subprocess_env, "SCRIPT_NAME", script_name); apr_table_do(copy_env, env, r->subprocess_env, NULL); version = newAV(); av_push(version, newSViv(1)); av_push(version, newSViv(0)); (void) hv_store(env, "psgi.version", 12, newRV_noinc((SV *) version), 0); url_scheme = apr_table_get(r->subprocess_env, "HTTPS") == NULL ? "http" : "https"; (void) hv_store(env, "psgi.url_scheme", 15, newSVpv(url_scheme, 0), 0); input = newRV_noinc(newSV(0)); sv_magic(SvRV(input), NULL, PERL_MAGIC_ext, NULL, 0); mg_find(SvRV(input), PERL_MAGIC_ext)->mg_obj = (void *) r; sv_bless(input, gv_stashpv("ModPSGI::Input", 1)); (void) hv_store(env, "psgi.input", 10, input, 0); errors = newRV_noinc(newSV(0)); sv_magic(SvRV(errors), NULL, PERL_MAGIC_ext, NULL, 0); mg_find(SvRV(errors), PERL_MAGIC_ext)->mg_obj = (void *) r; sv_bless(errors, gv_stashpv("ModPSGI::Errors", 1)); (void) hv_store(env, "psgi.errors", 11, errors, 0); (void) hv_store(env, "psgi.multithread", 16, newSViv(psgi_multithread), 0); (void) hv_store(env, "psgi.multiprocess", 17, newSViv(psgi_multiprocess), 0); (void) hv_store(env, "psgi.run_once", 13, newSViv(0), 0); (void) hv_store(env, "psgi.nonblocking", 16, newSViv(0), 0); return newRV_inc((SV *) env); }
static const char *set_modauthopenid_ax_require(cmd_parms *parms, void *mconfig, const char *alias, const char *uri, const char *pattern) { modauthopenid_config *s_cfg = (modauthopenid_config *) mconfig; s_cfg->use_ax = true; *(const char **)apr_array_push(s_cfg->ax_attrs) = alias; apr_table_set(s_cfg->ax_attr_uris, alias, uri); apr_table_set(s_cfg->ax_attr_patterns, alias, pattern); return NULL; }
static void DefineInit(apr_pool_t *p) { tDefines = apr_table_make(p, 10); /* predefine delimiters */ apr_table_set(tDefines, CreateNewVarName("escape", "mod_define", p), DEFAULT_MC_ESCAPE); apr_table_set(tDefines, "mod_define::dollar", DEFAULT_MC_DOLLAR); apr_table_set(tDefines, "mod_define::open", DEFAULT_MC_BRACEOPEN); apr_table_set(tDefines, "mod_define::close", DEFAULT_MC_BRACECLOSE); apr_table_set(tDefines, "mod_define::empty", ""); apr_pool_cleanup_register(p, NULL, DefineCleanup, apr_pool_cleanup_null); return; }
/* Handler for a AddExternalGroup server config line - add a external group * type to the server configuration */ static const char *add_extgroup(cmd_parms *cmd, void *dummy, const char *keyword, const char *path) { authnz_external_svr_config_rec *svr= (authnz_external_svr_config_rec *) ap_get_module_config( cmd->server->module_config, &authnz_external_module); apr_table_set( svr->group_path, keyword, path ); apr_table_set( svr->group_method, keyword, DEFAULT_METHOD ); return NULL; }
/* Handler for a DefineExternalAuth server config line */ static const char *def_extauth(cmd_parms *cmd, void *dummy, const char *keyword, const char *method, const char *path) { authnz_external_svr_config_rec *svr= (authnz_external_svr_config_rec *) ap_get_module_config( cmd->server->module_config, &authnz_external_module); apr_table_set( svr->auth_path, keyword, path ); apr_table_set( svr->auth_method, keyword, method ); return NULL; }
static void set_geoip_output(geoip_server_config_rec * cfg, request_rec * r, const char *key, const char *value) { if (value) { if (cfg->GeoIPOutput & GEOIP_NOTES) { apr_table_set(r->notes, key, value); } if (cfg->GeoIPOutput & GEOIP_ENV) { apr_table_set(r->subprocess_env, key, value); } } }
static void osrfHttpTranslatorInitHeaders(osrfHttpTranslator* trans, transport_message* msg) { apr_table_set(trans->apreq->headers_out, OSRF_HTTP_HEADER_FROM, msg->sender); apr_table_set(trans->apreq->headers_out, OSRF_HTTP_HEADER_THREAD, trans->thread); if(trans->multipart) { sprintf(contentTypeBuf, MULTIPART_CONTENT_TYPE, trans->delim); contentTypeBuf[79] = '\0'; osrfLogDebug(OSRF_LOG_MARK, "content type %s : %s : %s", MULTIPART_CONTENT_TYPE, trans->delim, contentTypeBuf); ap_set_content_type(trans->apreq, contentTypeBuf); ap_rprintf(trans->apreq, "--%s\n", trans->delim); } else { ap_set_content_type(trans->apreq, JSON_CONTENT_TYPE); } }
static void table_unset(abts_case *tc, void *data) { const char *val; apr_table_t *t = apr_table_make(p, 1); apr_table_set(t, "a", "1"); apr_table_set(t, "b", "2"); apr_table_unset(t, "b"); ABTS_INT_EQUAL(tc, 1, apr_table_elts(t)->nelts); val = apr_table_get(t, "a"); ABTS_STR_EQUAL(tc, "1", val); val = apr_table_get(t, "b"); ABTS_PTR_EQUAL(tc, (void *)NULL, (void *)val); }
SV *modperl_table_get_set(pTHX_ apr_table_t *table, char *key, SV *sv_val, int do_taint) { SV *retval = &PL_sv_undef; if (table == NULL) { /* do nothing */ } else if (key == NULL) { retval = modperl_hash_tie(aTHX_ "APR::Table", (SV *)NULL, (void*)table); } else if (!sv_val) { /* no val was passed */ char *val; if ((val = (char *)apr_table_get(table, key))) { retval = newSVpv(val, 0); } else { retval = newSV(0); } if (do_taint) { SvTAINTED_on(retval); } } else if (!SvOK(sv_val)) { /* val was passed in as undef */ apr_table_unset(table, key); } else { apr_table_set(table, key, SvPV_nolen(sv_val)); } return retval; }
/* Set RTSP client config struct with param, val pair. */ static int process_mrcpv1_config(rtsp_client_config_t *config, mrcp_sig_settings_t *sig_settings, const char *param, const char *val, apr_pool_t *pool) { int mine = 1; if ((config == NULL) || (param == NULL) || (sig_settings == NULL) || (val == NULL) || (pool == NULL)) return mine; if (strcasecmp(param, "server-ip") == 0) sig_settings->server_ip = ip_addr_get(val, pool); else if (strcasecmp(param, "server-port") == 0) sig_settings->server_port = (apr_port_t)atol(val); else if (strcasecmp(param, "resource-location") == 0) sig_settings->resource_location = apr_pstrdup(pool, val); else if (strcasecmp(param, "sdp-origin") == 0) config->origin = apr_pstrdup(pool, val); else if (strcasecmp(param, "max-connection-count") == 0) config->max_connection_count = atol(val); else if (strcasecmp(param, "force-destination") == 0) sig_settings->force_destination = atoi(val); else if ((strcasecmp(param, "speechsynth") == 0) || (strcasecmp(param, "speechrecog") == 0)) apr_table_set(sig_settings->resource_map, param, val); else mine = 0; return mine; }
static int php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers) { php_struct *ctx = SG(server_context); const char *sline = SG(sapi_headers).http_status_line; ctx->r->status = SG(sapi_headers).http_response_code; /* httpd requires that r->status_line is set to the first digit of * the status-code: */ if (sline && strlen(sline) > 12 && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ') { ctx->r->status_line = apr_pstrdup(ctx->r->pool, sline + 9); ctx->r->proto_num = 1000 + (sline[7]-'0'); if ((sline[7]-'0') == 0) { apr_table_set(ctx->r->subprocess_env, "force-response-1.0", "true"); } } /* call ap_set_content_type only once, else each time we call it, configured output filters for that content type will be added */ if (!ctx->content_type) { ctx->content_type = sapi_get_default_content_type(); } ap_set_content_type(ctx->r, apr_pstrdup(ctx->r->pool, ctx->content_type)); efree(ctx->content_type); ctx->content_type = NULL; return SAPI_HEADER_SENT_SUCCESSFULLY; }
mapcache_http_response *mapcache_core_get_featureinfo(mapcache_context *ctx, mapcache_request_get_feature_info *req_fi) { mapcache_feature_info *fi = req_fi->fi; mapcache_tileset *tileset = fi->map.tileset; if(!tileset->source) { ctx->set_error(ctx,404,"cannot query tileset %s: no source defined",tileset->name); return NULL; } if(tileset->source->info_formats) { int i; mapcache_http_response *response; for(i=0; i<tileset->source->info_formats->nelts; i++) { if(!strcmp(fi->format, APR_ARRAY_IDX(tileset->source->info_formats,i,char*))) { break; } } if(i == tileset->source->info_formats->nelts) { ctx->set_error(ctx,404, "unsupported feature info format %s",fi->format); return NULL; } tileset->source->query_info(ctx,fi); if(GC_HAS_ERROR(ctx)) return NULL; response = mapcache_http_response_create(ctx->pool); response->data = fi->data; apr_table_set(response->headers,"Content-Type",fi->format); return response; } else {
/** Load UniRTSP signaling agent */ static apt_bool_t unimrcp_server_rtsp_uas_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root, const char *id) { const apr_xml_elem *elem; mrcp_sig_agent_t *agent; rtsp_server_config_t *config; config = mrcp_unirtsp_server_config_alloc(loader->pool); config->origin = DEFAULT_SDP_ORIGIN; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading UniRTSP Agent <%s>",id); for(elem = root->first_child; elem; elem = elem->next) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Element <%s>",elem->name); if(strcasecmp(elem->name,"rtsp-ip") == 0) { config->local_ip = unimrcp_server_ip_address_get(loader,elem); } else if(strcasecmp(elem->name,"rtsp-port") == 0) { if(is_cdata_valid(elem) == TRUE) { config->local_port = (apr_port_t)atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"sdp-origin") == 0) { if(is_cdata_valid(elem) == TRUE) { config->origin = cdata_copy(elem,loader->pool); } } else if(strcasecmp(elem->name,"max-connection-count") == 0) { if(is_cdata_valid(elem) == TRUE) { config->max_connection_count = atol(cdata_text_get(elem)); } } else if(strcasecmp(elem->name,"force-destination") == 0) { if(is_cdata_valid(elem) == TRUE) { config->force_destination = cdata_bool_get(elem); } } else if(strcasecmp(elem->name,"resource-map") == 0) { const apr_xml_attr *name_attr; const apr_xml_attr *value_attr; const apr_xml_elem *child_elem; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Resource Map"); for(child_elem = elem->first_child; child_elem; child_elem = child_elem->next) { if(name_value_attribs_get(child_elem,&name_attr,&value_attr) == TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Param %s:%s",name_attr->value,value_attr->value); apr_table_set(config->resource_map,name_attr->value,value_attr->value); } } } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } if(!config->local_ip) { /* use default ip address if not specified */ config->local_ip = apr_pstrdup(loader->pool,loader->ip); } agent = mrcp_unirtsp_server_agent_create(id,config,loader->pool); return mrcp_server_signaling_agent_register(loader->server,agent); }
aos_status_t *oss_copy_object(const oss_request_options_t *options, const aos_string_t *source_bucket, const aos_string_t *source_object, const aos_string_t *dest_bucket, const aos_string_t *dest_object, aos_table_t *headers, aos_table_t **resp_headers) { char *copy_source = NULL; aos_status_t *s = NULL; aos_http_request_t *req = NULL; aos_http_response_t *resp = NULL; aos_table_t *query_params = NULL; headers = aos_table_create_if_null(options, headers, 2); query_params = aos_table_create_if_null(options, query_params, 0); /* init headers */ copy_source = apr_psprintf(options->pool, "/%.*s/%.*s", source_bucket->len, source_bucket->data, source_object->len, source_object->data); apr_table_set(headers, OSS_CANNONICALIZED_HEADER_COPY_SOURCE, copy_source); set_content_type(NULL, dest_object->data, headers); oss_init_object_request(options, dest_bucket, dest_object, HTTP_PUT, &req, query_params, headers, &resp); s = oss_process_request(options, req, resp); *resp_headers = resp->headers; return s; }
static int post_read_handler(request_rec *r) { conn_rec *c = r->connection; my_config *conf = ap_get_module_config (c->base_server->module_config, &myfixip_module); const char *new_ip = NULL; // Save original IP save_req_ip(r); new_ip = apr_table_get(c->notes, NOTE_REWRITE_IP); if (conf->resetHeader || new_ip || !check_trusted(c, conf)) { apr_table_unset(r->headers_in, HDR_USERAGENT_IP); } if (new_ip) { // Set Header apr_table_set(r->headers_in, HDR_USERAGENT_IP, new_ip); } else { // Get Header new_ip = apr_table_get(r->headers_in, HDR_USERAGENT_IP); } #ifdef DEBUG ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, MODULE_NAME "::post_read_handler IP Connection from: %s:%d [%s] to port=%d newip=%s (OK)", _CLIENT_IP, _CLIENT_ADDR->port, _USERAGENT_IP, c->local_addr->port, new_ip); #endif if (new_ip && strcmp(_USERAGENT_IP, new_ip)) { // Change rewrite_req_ip(r, new_ip); } return DECLINED; }
/* This functions will find out, if the URI contains a __cookie_try parameter. This is important in the very beginning of a mod_but session, while we are trying to find out, if the client has cookie support enabled. return = 0 no __cookie_try in URL return = 1 there is a __cookie_try in URL */ void find_cookie_try(request_rec *r) { apr_status_t ret = 0; char *p = strstr(r->args, "__cookie_try"); if(p) { p += strlen("__cookie_try"); if(*p == '=') { char *cid = (char *)apr_pstrdup(r->pool, p+1); if(cid) { p = strchr(cid, '&'); if(p) *p = '\0'; apr_table_set(r->notes, "COOKIE_TRY" , cid); ap_log_rerror(PC_LOG_INFO, r, "mod_but_access.c: COOKIE_TRY IS %s", apr_table_get(r->notes, "COOKIE_TRY")); ret = 1; } } } if(!ret) { ap_log_rerror(PC_LOG_INFO, r, "mod_but_access.c: PROBLEM"); } }
static void table_nelts(abts_case *tc, void *data) { const char *val; apr_table_t *t = apr_table_make(p, 1); apr_table_set(t, "abc", "def"); apr_table_set(t, "def", "abc"); apr_table_set(t, "foo", "zzz"); val = apr_table_get(t, "foo"); ABTS_STR_EQUAL(tc, "zzz", val); val = apr_table_get(t, "abc"); ABTS_STR_EQUAL(tc, "def", val); val = apr_table_get(t, "def"); ABTS_STR_EQUAL(tc, "abc", val); ABTS_INT_EQUAL(tc, 3, apr_table_elts(t)->nelts); }
apr_status_t dav_svn__location_header_filter(ap_filter_t *f, apr_bucket_brigade *bb) { request_rec *r = f->r; const char *master_uri; const char *location, *start_foo = NULL; /* Don't filter if we're in a subrequest or we aren't setup to proxy anything. */ master_uri = dav_svn__get_master_uri(r); master_uri = svn_path_uri_encode(master_uri, r->pool); if (r->main || !master_uri) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } location = apr_table_get(r->headers_out, "Location"); if (location) { start_foo = ap_strstr_c(location, master_uri); } if (start_foo) { const char *new_uri; start_foo += strlen(master_uri); new_uri = ap_construct_url(r->pool, apr_pstrcat(r->pool, dav_svn__get_root_dir(r), "/", start_foo, SVN_VA_NULL), r); apr_table_set(r->headers_out, "Location", new_uri); } return ap_pass_brigade(f->next, bb); }
static void argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms) { char *key; char *value; char *strtok_state; key = apr_strtok(str, "&", &strtok_state); while (key) { value = strchr(key, '='); if (value) { *value = '\0'; /* Split the string in two */ value++; /* Skip passed the = */ } else { value = "1"; } ap_unescape_url(key); ap_unescape_url(value); apr_table_set(parms, key, value); /* ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Found query arg: %s = %s", key, value); */ key = apr_strtok(NULL, "&", &strtok_state); } }
static int write_http_response(mapcache_context_apache_request *ctx, mapcache_http_response *response) { request_rec *r = ctx->request; int rc; if(response->mtime) { ap_update_mtime(r, response->mtime); if((rc = ap_meets_conditions(r)) != OK) { return rc; } char *timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN); apr_rfc822_date(timestr, response->mtime); apr_table_setn(r->headers_out, "Last-Modified", timestr); } if(response->headers && !apr_is_empty_table(response->headers)) { const apr_array_header_t *elts = apr_table_elts(response->headers); int i; for(i=0;i<elts->nelts;i++) { apr_table_entry_t entry = APR_ARRAY_IDX(elts,i,apr_table_entry_t); if(!strcasecmp(entry.key,"Content-Type")) { ap_set_content_type(r,entry.val); } else { apr_table_set(r->headers_out, entry.key, entry.val); } } } if(response->data) { ap_set_content_length(r,response->data->size); ap_rwrite((void*)response->data->buf, response->data->size, r); } r->status = response->code; return OK; }
static int table_ass_subscript(tableobject *self, PyObject *key, PyObject *val) { char *k; if (key && !PyString_Check(key)) { PyErr_SetString(PyExc_TypeError, "table keys must be strings"); return -1; } k = PyString_AsString(key); if (val == NULL) { apr_table_unset(self->table, k); } else { if (val && !PyString_Check(val)) { PyErr_SetString(PyExc_TypeError, "table values must be strings"); return -1; } apr_table_set(self->table, k, PyString_AsString(val)); } return 0; }
/** * \private \memberof mapcache_source_wms * \sa mapcache_source::configuration_parse() */ void _mapcache_source_wms_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_source *source) { ezxml_t cur_node; mapcache_source_wms *src = (mapcache_source_wms*)source; if ((cur_node = ezxml_child(node,"getmap")) != NULL) { ezxml_t gm_node; if ((gm_node = ezxml_child(cur_node,"params")) != NULL) { for(gm_node = gm_node->child; gm_node; gm_node = gm_node->sibling) { apr_table_set(src->getmap_params, gm_node->name, gm_node->txt); } } else { ctx->set_error(ctx,400,"wms source %s <getmap> has no <params> block (should contain at least <LAYERS> child)",source->name); return; } } else { ctx->set_error(ctx,400,"wms source %s has no <getmap> block",source->name); return; } if ((cur_node = ezxml_child(node,"getfeatureinfo")) != NULL) { ezxml_t fi_node; if ((fi_node = ezxml_child(cur_node,"info_formats")) != NULL) { char *key,*last; char *iformats; source->info_formats = apr_array_make(ctx->pool,3,sizeof(char*)); iformats = apr_pstrdup(ctx->pool,fi_node->txt); for (key = apr_strtok(iformats, "," , &last); key != NULL; key = apr_strtok(NULL, ",", &last)) { APR_ARRAY_PUSH(source->info_formats,char*) = key; } } else {
static int set_session_cookie(request_rec *r, modauthopenid_config *s_cfg, opkele::params_t& params, std::string identity) { // now set auth cookie, if we're doing session based auth std::string session_id, hostname, path, cookie_value, redirect_location, args; if(s_cfg->cookie_path != NULL) path = std::string(s_cfg->cookie_path); else modauthopenid::base_dir(std::string(r->uri), path); modauthopenid::make_rstring(32, session_id); modauthopenid::make_cookie_value(cookie_value, std::string(s_cfg->cookie_name), session_id, path, s_cfg->cookie_lifespan); APDEBUG(r, "Setting cookie after authentication of user %s", identity.c_str()); apr_table_set(r->err_headers_out, "Set-Cookie", cookie_value.c_str()); hostname = std::string(r->hostname); // save session values modauthopenid::SessionManager sm(std::string(s_cfg->db_location)); sm.store_session(session_id, hostname, path, identity, s_cfg->cookie_lifespan); sm.close(); opkele::params_t ext_params; modauthopenid::get_extension_params(ext_params, params); modauthopenid::remove_openid_vars(params); modauthopenid::merge_params(ext_params, params); args = params.append_query("", "").substr(1); if(args.length() == 0) r->args = NULL; else apr_cpystrn(r->args, args.c_str(), 1024); full_uri(r, redirect_location, s_cfg); return modauthopenid::http_redirect(r, redirect_location); };
static char *last_not_in_array(request_rec *r, apr_array_header_t *forwarded_for, apr_array_header_t *proxy_ips) { apr_sockaddr_t *sa; apr_status_t rv; char **fwd_ips, *proxy_list; int i, earliest_legit_i = 0; proxy_list = apr_pstrdup(r->pool, r->DEF_IP); fwd_ips = (char **)forwarded_for->elts; for (i = (forwarded_for->nelts); i > 0; ) { i--; rv = apr_sockaddr_info_get(&sa, fwd_ips[i], APR_UNSPEC, 0, 0, r->pool); if (rv == APR_SUCCESS) { earliest_legit_i = i; if (!is_in_array(sa, proxy_ips)) break; proxy_list = apr_pstrcat(r->pool, proxy_list, ", ", fwd_ips[i], NULL); } else { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r, "mod_rpaf: forwarded-for list entry of %s is not a valid IP", fwd_ips[i]); } } if (i > 0 || rv == APR_SUCCESS || earliest_legit_i) { /* remoteip-proxy-ip_list r->notes entry is forward compatible with Apache2.4 mod_remoteip*/ apr_table_set(r->notes, "remoteip-proxy-ip-list", proxy_list); return fwd_ips[earliest_legit_i]; } else { return NULL; } }