| 180 | } header_dptr; |
| 181 | static ap_regex_t *warn_rx; |
| 182 | static int clean_warning_headers(void *data, const char *key, const char *val) |
| 183 | { |
| 184 | apr_table_t *headers = ((header_dptr*)data)->table; |
| 185 | apr_pool_t *pool = ((header_dptr*)data)->pool; |
| 186 | char *warning; |
| 187 | char *date; |
| 188 | apr_time_t warn_time; |
| 189 | const int nmatch = 3; |
| 190 | ap_regmatch_t pmatch[3]; |
| 191 | |
| 192 | if (headers == NULL) { |
| 193 | ((header_dptr*)data)->table = headers = apr_table_make(pool, 2); |
| 194 | } |
| 195 | /* |
| 196 | * Parse this, suckers! |
| 197 | * |
| 198 | * Warning = "Warning" ":" 1#warning-value |
| 199 | * |
| 200 | * warning-value = warn-code SP warn-agent SP warn-text |
| 201 | * [SP warn-date] |
| 202 | * |
| 203 | * warn-code = 3DIGIT |
| 204 | * warn-agent = ( host [ ":" port ] ) | pseudonym |
| 205 | * ; the name or pseudonym of the server adding |
| 206 | * ; the Warning header, for use in debugging |
| 207 | * warn-text = quoted-string |
| 208 | * warn-date = <"> HTTP-date <"> |
| 209 | * |
| 210 | * Buggrit, use a bloomin' regexp! |
| 211 | * (\d{3}\s+\S+\s+\".*?\"(\s+\"(.*?)\")?) --> whole in $1, date in $3 |
| 212 | */ |
| 213 | while (!ap_regexec(warn_rx, val, nmatch, pmatch, 0)) { |
| 214 | warning = apr_pstrndup(pool, val+pmatch[0].rm_so, |
| 215 | pmatch[0].rm_eo - pmatch[0].rm_so); |
| 216 | warn_time = 0; |
| 217 | if (pmatch[2].rm_eo > pmatch[2].rm_so) { |
| 218 | /* OK, we have a date here */ |
| 219 | date = apr_pstrndup(pool, val+pmatch[2].rm_so, |
| 220 | pmatch[2].rm_eo - pmatch[2].rm_so); |
| 221 | warn_time = apr_date_parse_http(date); |
| 222 | } |
| 223 | if (!warn_time || (warn_time == ((header_dptr*)data)->time)) { |
| 224 | apr_table_addn(headers, key, warning); |
| 225 | } |
| 226 | val += pmatch[0].rm_eo; |
| 227 | } |
| 228 | return 1; |
| 229 | } |
| 230 | static apr_table_t *ap_proxy_clean_warnings(apr_pool_t *p, apr_table_t *headers) |
| 231 | { |
| 232 | header_dptr x; |
nothing calls this directly
no test coverage detected