Skip to content

Commit f04dcc6

Browse files
committed
updates to handle tsapi TSResponseAction
1 parent 47025c5 commit f04dcc6

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

src/proxy/http/HttpTransact.cc

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,29 +144,31 @@ bypass_ok(HttpTransact::State *s)
144144
inline static bool
145145
host_override(HttpTransact::State *s)
146146
{
147-
bool res = false;
148-
if (nullptr != s->next_hop_strategy) {
147+
if (s->response_action.handled) { // should be handled by the plugin
148+
return false;
149+
} else if (nullptr != s->next_hop_strategy) {
149150
// remap strategies do not support the TSHttpTxnParentProxySet API.
150-
res = s->next_hop_strategy->host_override;
151+
return s->next_hop_strategy->host_override;
151152
} else if (nullptr != s->parent_params) {
152-
res = s->parent_result.host_override();
153+
return s->parent_result.host_override();
153154
}
154-
return res;
155+
return false;
155156
}
156157
157158
// wrapper to choose between a remap next hop strategy or use parent.config
158159
// remap next hop strategy is preferred
159160
inline static bool
160161
is_some(HttpTransact::State *s)
161162
{
162-
bool res = false;
163-
if (nullptr != s->next_hop_strategy) {
163+
if (s->response_action.handled) {
164+
return true;
165+
} else if (nullptr != s->next_hop_strategy) {
164166
// remap strategies do not support the TSHttpTxnParentProxySet API.
165-
res = s->parent_result.result == ParentResultType::SPECIFIED;
167+
return s->parent_result.result == ParentResultType::SPECIFIED;
166168
} else if (nullptr != s->parent_params) {
167-
res = s->parent_result.is_some();
169+
return s->parent_result.is_some();
168170
}
169-
return res;
171+
return false;
170172
}
171173
172174
// wrapper to choose between a remap next hop strategy or use parent.config
@@ -628,14 +630,11 @@ find_server_and_update_current_info(HttpTransact::State *s)
628630
TxnDbg(dbg_ctl_http_trans, "request is from localhost, so bypass parent");
629631
s->parent_result.result = ParentResultType::DIRECT;
630632
} else if (s->method == HTTP_WKSIDX_CONNECT && s->http_config_param->disable_ssl_parenting) {
631-
/// BNO
632-
633633
if (s->parent_result.result == ParentResultType::SPECIFIED) {
634634
nextParent(s);
635635
} else {
636636
findParent(s);
637637
}
638-
639638
if (!is_some(s) || is_api_result(s) || parent_is_proxy(s)) {
640639
TxnDbg(dbg_ctl_http_trans, "request not cacheable, so bypass parent");
641640
s->parent_result.result = ParentResultType::DIRECT;
@@ -702,17 +701,20 @@ find_server_and_update_current_info(HttpTransact::State *s)
702701
switch (s->parent_result.result) {
703702
case ParentResultType::SPECIFIED: {
704703
char const *const hostname = s->parent_result.hostname;
705-
s->parent_info.name = s->arena.str_store(hostname, strlen(hostname));
706-
707-
// if host header override option enabled
708-
if (host_override(s)) {
709-
TxnDbg(dbg_ctl_http_trans, "overriding host header with parent %s", hostname);
710-
if (!s->hdr_info.server_request.valid()) {
711-
s->hdr_info.client_request.value_set(static_cast<std::string_view>(MIME_FIELD_HOST), hostname);
712-
s->hdr_info.client_request.mark_target_dirty();
713-
} else {
714-
s->hdr_info.server_request.value_set(static_cast<std::string_view>(MIME_FIELD_HOST), hostname);
715-
s->hdr_info.server_request.mark_target_dirty();
704+
705+
if (nullptr != hostname) {
706+
s->parent_info.name = s->arena.str_store(hostname, strlen(hostname));
707+
708+
// if host header override option enabled
709+
if (host_override(s)) {
710+
TxnDbg(dbg_ctl_http_trans, "overriding host header with parent %s", hostname);
711+
if (!s->hdr_info.server_request.valid()) {
712+
s->hdr_info.client_request.value_set(static_cast<std::string_view>(MIME_FIELD_HOST), hostname);
713+
s->hdr_info.client_request.mark_target_dirty();
714+
} else {
715+
s->hdr_info.server_request.value_set(static_cast<std::string_view>(MIME_FIELD_HOST), hostname);
716+
s->hdr_info.server_request.mark_target_dirty();
717+
}
716718
}
717719
}
718720

0 commit comments

Comments
 (0)