static am_status_t set_method(am_request_t *rq) { request_rec *r = (request_rec *) (rq != NULL ? rq->ctx : NULL); if (r == NULL) return AM_EINVAL; r->method = am_method_num_to_str(rq->method); r->method_number = ap_method_number_of(r->method); return AM_SUCCESS; }
static char get_method_num(request_rec *r, unsigned long instance_id) { const char *thisfunc = "get_method_num():"; char method_num = AM_REQUEST_UNKNOWN; const char *mthd = ap_method_name_of(r->pool, r->method_number); am_log_debug(instance_id, "%s method %s (%s, %d)", thisfunc, LOGEMPTY(r->method), LOGEMPTY(mthd), r->method_number); if (r->method_number == M_GET && r->header_only > 0) { method_num = AM_REQUEST_HEAD; } else { method_num = am_method_str_to_num(mthd); } am_log_debug(instance_id, "%s number corresponds to %s method", thisfunc, am_method_num_to_str(method_num)); /* check if method number and method string correspond */ if (method_num == AM_REQUEST_UNKNOWN) { /* if method string is not null, set the correct method number */ if (r->method != NULL && *(r->method) != '\0') { method_num = am_method_str_to_num(r->method); r->method_number = ap_method_number_of(r->method); am_log_debug(instance_id, "%s set method number to correspond to %s method (%d)", thisfunc, r->method, r->method_number); } } else if (ISVALID(r->method) && strcasecmp(r->method, am_method_num_to_str(method_num)) && (method_num != AM_REQUEST_INVALID)) { /* in case the method number and the method string do not match, * correct the method string. But if the method number is invalid * the method string needs to be preserved in case Apache is * used as a proxy (in front of Exchange Server for instance) */ r->method = am_method_num_to_str(method_num); am_log_debug(instance_id, "%s set method to %s", thisfunc, LOGEMPTY(r->method)); } return method_num; }
static const char *am_allowmethods(cmd_parms *cmd, void *d, int argc, char *const argv[]) { int i; am_conf_t *conf = (am_conf_t *)d; if (argc == 0) { return "AllowMethods: No method or 'reset' keyword given"; } if (argc == 1) { if (strcasecmp("reset", argv[0]) == 0) { conf->allowed = 0; conf->allowed_set = 1; return NULL; } } for (i = 0; i < argc; i++) { int m; m = ap_method_number_of(argv[i]); if (m == M_INVALID) { return apr_pstrcat(cmd->pool, "AllowMethods: Invalid Method '", argv[i], "'", NULL); } conf->allowed |= (AP_METHOD_BIT << m); } conf->allowed_set = 1; return NULL; }
static request_rec *h2_task_create_request(h2_task_env *env) { conn_rec *conn = &env->c; request_rec *r; apr_pool_t *p; int access_status = HTTP_OK; apr_pool_create(&p, conn->pool); apr_pool_tag(p, "request"); r = apr_pcalloc(p, sizeof(request_rec)); AP_READ_REQUEST_ENTRY((intptr_t)r, (uintptr_t)conn); r->pool = p; r->connection = conn; r->server = conn->base_server; r->user = NULL; r->ap_auth_type = NULL; r->allowed_methods = ap_make_method_list(p, 2); r->headers_in = apr_table_copy(r->pool, env->headers); r->trailers_in = apr_table_make(r->pool, 5); r->subprocess_env = apr_table_make(r->pool, 25); r->headers_out = apr_table_make(r->pool, 12); r->err_headers_out = apr_table_make(r->pool, 5); r->trailers_out = apr_table_make(r->pool, 5); r->notes = apr_table_make(r->pool, 5); r->request_config = ap_create_request_config(r->pool); /* Must be set before we run create request hook */ r->proto_output_filters = conn->output_filters; r->output_filters = r->proto_output_filters; r->proto_input_filters = conn->input_filters; r->input_filters = r->proto_input_filters; ap_run_create_request(r); r->per_dir_config = r->server->lookup_defaults; r->sent_bodyct = 0; /* bytect isn't for body */ r->read_length = 0; r->read_body = REQUEST_NO_BODY; r->status = HTTP_OK; /* Until further notice */ r->header_only = 0; r->the_request = NULL; /* Begin by presuming any module can make its own path_info assumptions, * until some module interjects and changes the value. */ r->used_path_info = AP_REQ_DEFAULT_PATH_INFO; r->useragent_addr = conn->client_addr; r->useragent_ip = conn->client_ip; ap_run_pre_read_request(r, conn); /* Time to populate r with the data we have. */ r->request_time = apr_time_now(); r->the_request = apr_psprintf(r->pool, "%s %s HTTP/1.1", env->method, env->path); r->method = env->method; /* Provide quick information about the request method as soon as known */ r->method_number = ap_method_number_of(r->method); if (r->method_number == M_GET && r->method[0] == 'H') { r->header_only = 1; } ap_parse_uri(r, env->path); r->protocol = (char*)"HTTP/1.1"; r->proto_num = HTTP_VERSION(1, 1); r->hostname = env->authority; /* update what we think the virtual host is based on the headers we've * now read. may update status. */ ap_update_vhost_from_headers(r); /* we may have switched to another server */ r->per_dir_config = r->server->lookup_defaults; /* * Add the HTTP_IN filter here to ensure that ap_discard_request_body * called by ap_die and by ap_send_error_response works correctly on * status codes that do not cause the connection to be dropped and * in situations where the connection should be kept alive. */ ap_add_input_filter_handle(ap_http_input_filter_handle, NULL, r, r->connection); if (access_status != HTTP_OK || (access_status = ap_run_post_read_request(r))) { /* Request check post hooks failed. An example of this would be a * request for a vhost where h2 is disabled --> 421. */ h2_task_die(env, access_status, r); ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, r); ap_run_log_transaction(r); r = NULL; goto traceout; } AP_READ_REQUEST_SUCCESS((uintptr_t)r, (char *)r->method, (char *)r->uri, (char *)r->server->defn_name, r->status); return r; traceout: AP_READ_REQUEST_FAILURE((uintptr_t)r); return r; }