|
| 1 | +/* Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | + * contributor license agreements. See the NOTICE file distributed with |
| 3 | + * this work for additional information regarding copyright ownership. |
| 4 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | + * (the "License"); you may not use this file except in compliance with |
| 6 | + * the License. You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | + |
| 18 | +/** |
| 19 | + * @file mod_request.h |
| 20 | + * @brief mod_request private header file |
| 21 | + * |
| 22 | + * @defgroup MOD_REQUEST mod_request |
| 23 | + * @ingroup APACHE_MODS |
| 24 | + * @{ |
| 25 | + */ |
| 26 | + |
| 27 | +#ifndef MOD_REQUEST_H |
| 28 | +#define MOD_REQUEST_H |
| 29 | + |
| 30 | +#include "apr.h" |
| 31 | +#include "apr_buckets.h" |
| 32 | + |
| 33 | +#include "httpd.h" |
| 34 | +#include "util_filter.h" |
| 35 | + |
| 36 | + |
| 37 | +#ifdef __cplusplus |
| 38 | +extern "C" { |
| 39 | +#endif |
| 40 | + |
| 41 | +extern module AP_MODULE_DECLARE_DATA request_module; |
| 42 | + |
| 43 | +#define KEEP_BODY_FILTER "KEEP_BODY" |
| 44 | +#define KEPT_BODY_FILTER "KEPT_BODY" |
| 45 | + |
| 46 | +/** |
| 47 | + * Core per-directory configuration. |
| 48 | + */ |
| 49 | +typedef struct { |
| 50 | + apr_off_t keep_body; |
| 51 | + int keep_body_set; |
| 52 | +} request_dir_conf; |
| 53 | + |
| 54 | +/* Handles for core filters */ |
| 55 | +extern AP_DECLARE_DATA ap_filter_rec_t *ap_keep_body_input_filter_handle; |
| 56 | +extern AP_DECLARE_DATA ap_filter_rec_t *ap_kept_body_input_filter_handle; |
| 57 | + |
| 58 | +/* Filter to set aside a kept body on subrequests */ |
| 59 | +AP_DECLARE(apr_status_t) ap_keep_body_filter(ap_filter_t *f, apr_bucket_brigade *b, |
| 60 | + ap_input_mode_t mode, apr_read_type_e block, |
| 61 | + apr_off_t readbytes); |
| 62 | + |
| 63 | +/* Filter to insert a kept body on subrequests */ |
| 64 | +AP_DECLARE(apr_status_t) ap_kept_body_filter(ap_filter_t *f, apr_bucket_brigade *b, |
| 65 | + ap_input_mode_t mode, apr_read_type_e block, |
| 66 | + apr_off_t readbytes); |
| 67 | + |
| 68 | +/** |
| 69 | + * Structure to store the contents of an HTTP form of the type |
| 70 | + * application/x-www-form-urlencoded. |
| 71 | + * |
| 72 | + * Currently it contains the name as a char* of maximum length |
| 73 | + * HUGE_STRING_LEN, and a value in the form of a bucket brigade |
| 74 | + * of arbitrary length. |
| 75 | + */ |
| 76 | +typedef struct { |
| 77 | + const char *name; |
| 78 | + apr_bucket_brigade *value; |
| 79 | +} ap_form_pair_t; |
| 80 | + |
| 81 | +/** |
| 82 | + * Read the body and parse any form found, which must be of the |
| 83 | + * type application/x-www-form-urlencoded. |
| 84 | + * |
| 85 | + * Name/value pairs are returned in an array, with the names as |
| 86 | + * strings with a maximum length of HUGE_STRING_LEN, and the |
| 87 | + * values as bucket brigades. This allows values to be arbitrarily |
| 88 | + * large. |
| 89 | + * |
| 90 | + * All url-encoding is removed from both the names and the values |
| 91 | + * on the fly. The names are interpreted as strings, while the |
| 92 | + * values are interpreted as blocks of binary data, that may |
| 93 | + * contain the 0 character. |
| 94 | + * |
| 95 | + * In order to ensure that resource limits are not exceeded, a |
| 96 | + * maximum size must be provided. If the sum of the lengths of |
| 97 | + * the names and the values exceed this size, this function |
| 98 | + * will return HTTP_REQUEST_ENTITY_TOO_LARGE. |
| 99 | + * |
| 100 | + * An optional number of parameters can be provided, if the number |
| 101 | + * of parameters provided exceeds this amount, this function will |
| 102 | + * return HTTP_REQUEST_ENTITY_TOO_LARGE. If this value is negative, |
| 103 | + * no limit is imposed, and the number of parameters is in turn |
| 104 | + * constrained by the size parameter above. |
| 105 | + * |
| 106 | + * This function honours any kept_body configuration, and the |
| 107 | + * original raw request body will be saved to the kept_body brigade |
| 108 | + * if so configured, just as ap_discard_request_body does. |
| 109 | + * |
| 110 | + * NOTE: File upload is not yet supported, but can be without change |
| 111 | + * to the function call. |
| 112 | + */ |
| 113 | +AP_DECLARE(int) ap_parse_request_form(request_rec * r, apr_array_header_t ** ptr, |
| 114 | + apr_size_t num, apr_size_t size); |
| 115 | + |
| 116 | +APR_DECLARE_OPTIONAL_FN(void, ap_parse_request_form, (request_rec * r, apr_array_header_t ** ptr, |
| 117 | + apr_size_t num, apr_size_t size)); |
| 118 | + |
| 119 | +#ifdef __cplusplus |
| 120 | +} |
| 121 | +#endif |
| 122 | + |
| 123 | +#endif /* !MOD_REQUEST_H */ |
| 124 | +/** @} */ |
0 commit comments