| 7539 | } |
| 7540 | |
| 7541 | TSReturnCode |
| 7542 | TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char *value, int length) |
| 7543 | { |
| 7544 | sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); |
| 7545 | |
| 7546 | if (length == -1) { |
| 7547 | length = strlen(value); |
| 7548 | } |
| 7549 | |
| 7550 | HttpSM *s = reinterpret_cast<HttpSM *>(txnp); |
| 7551 | |
| 7552 | s->t_state.setup_per_txn_configs(); |
| 7553 | |
| 7554 | switch (conf) { |
| 7555 | case TS_CONFIG_HTTP_RESPONSE_SERVER_STR: |
| 7556 | if (value && length > 0) { |
| 7557 | s->t_state.my_txn_conf().proxy_response_server_string = const_cast<char *>(value); // The "core" likes non-const char* |
| 7558 | s->t_state.my_txn_conf().proxy_response_server_string_len = length; |
| 7559 | } else { |
| 7560 | s->t_state.my_txn_conf().proxy_response_server_string = nullptr; |
| 7561 | s->t_state.my_txn_conf().proxy_response_server_string_len = 0; |
| 7562 | } |
| 7563 | break; |
| 7564 | case TS_CONFIG_HTTP_GLOBAL_USER_AGENT_HEADER: |
| 7565 | if (value && length > 0) { |
| 7566 | s->t_state.my_txn_conf().global_user_agent_header = const_cast<char *>(value); // The "core" likes non-const char* |
| 7567 | s->t_state.my_txn_conf().global_user_agent_header_size = length; |
| 7568 | } else { |
| 7569 | s->t_state.my_txn_conf().global_user_agent_header = nullptr; |
| 7570 | s->t_state.my_txn_conf().global_user_agent_header_size = 0; |
| 7571 | } |
| 7572 | break; |
| 7573 | case TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE: |
| 7574 | if (value && length > 0) { |
| 7575 | s->t_state.my_txn_conf().body_factory_template_base = const_cast<char *>(value); |
| 7576 | s->t_state.my_txn_conf().body_factory_template_base_len = length; |
| 7577 | } else { |
| 7578 | s->t_state.my_txn_conf().body_factory_template_base = nullptr; |
| 7579 | s->t_state.my_txn_conf().body_factory_template_base_len = 0; |
| 7580 | } |
| 7581 | break; |
| 7582 | case TS_CONFIG_HTTP_INSERT_FORWARDED: |
| 7583 | if (value && length > 0) { |
| 7584 | swoc::LocalBufferWriter<1024> error; |
| 7585 | HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(std::string_view(value, length), error); |
| 7586 | if (!error.size()) { |
| 7587 | s->t_state.my_txn_conf().insert_forwarded = bs; |
| 7588 | } else { |
| 7589 | Error("HTTP %.*s", static_cast<int>(error.size()), error.data()); |
| 7590 | } |
| 7591 | } |
| 7592 | break; |
| 7593 | case TS_CONFIG_HTTP_SERVER_SESSION_SHARING_MATCH: |
| 7594 | if (value && length > 0) { |
| 7595 | HttpConfig::load_server_session_sharing_match(value, s->t_state.my_txn_conf().server_session_sharing_match); |
| 7596 | s->t_state.my_txn_conf().server_session_sharing_match_str = const_cast<char *>(value); |
| 7597 | } |
| 7598 | break; |