MCPcopy Create free account
hub / github.com/apache/httpd / header_inout_cmd

Function header_inout_cmd

modules/metadata/mod_headers.c:419–555  ·  view source on GitHub ↗

handle RequestHeader and Header directive */

Source from the content-addressed store, hash-verified

417
418/* handle RequestHeader and Header directive */
419static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd,
420 void *indirconf,
421 const char *action,
422 const char *hdr,
423 const char *value,
424 const char *subs,
425 const char *envclause)
426{
427 headers_conf *dirconf = indirconf;
428 const char *condition_var = NULL;
429 const char *colon;
430 header_entry *new;
431 ap_expr_info_t *expr = NULL;
432
433 apr_array_header_t *fixup = (cmd->info == &hdr_in)
434 ? dirconf->fixup_in : (cmd->info == &hdr_out_always)
435 ? dirconf->fixup_err
436 : dirconf->fixup_out;
437
438 new = (header_entry *) apr_array_push(fixup);
439
440 if (!strcasecmp(action, "set"))
441 new->action = hdr_set;
442 else if (!strcasecmp(action, "setifempty"))
443 new->action = hdr_setifempty;
444 else if (!strcasecmp(action, "add"))
445 new->action = hdr_add;
446 else if (!strcasecmp(action, "append"))
447 new->action = hdr_append;
448 else if (!strcasecmp(action, "merge"))
449 new->action = hdr_merge;
450 else if (!strcasecmp(action, "unset"))
451 new->action = hdr_unset;
452 else if (!strcasecmp(action, "echo"))
453 new->action = hdr_echo;
454 else if (!strcasecmp(action, "edit"))
455 new->action = hdr_edit;
456 else if (!strcasecmp(action, "edit*"))
457 new->action = hdr_edit_r;
458 else if (!strcasecmp(action, "note")) {
459 if (cmd->info == &hdr_in) {
460 return "RequestHeader does not support the 'note' action";
461 }
462 new->action = hdr_note;
463 }
464 else
465 return "first argument must be 'add', 'set', 'setifempty', 'append', 'merge', "
466 "'unset', 'echo', 'note', 'edit', or 'edit*'.";
467
468 if (new->action == hdr_edit || new->action == hdr_edit_r) {
469 if (subs == NULL) {
470 return "Header edit requires a match and a substitution";
471 }
472 new->regex = ap_pregcomp(cmd->pool, value, AP_REG_EXTENDED);
473 if (new->regex == NULL) {
474 return "Header edit regex could not be compiled";
475 }
476 new->subs = subs;

Callers 1

header_cmdFunction · 0.85

Calls 3

ap_pregcompFunction · 0.85
ap_strchr_cFunction · 0.85
parse_format_stringFunction · 0.85

Tested by

no test coverage detected