MCPcopy Create free account
hub / github.com/apache/trafficserver / EndRemapRequest

Method EndRemapRequest

src/proxy/http/HttpTransact.cc:1058–1247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1056}
1057
1058void
1059HttpTransact::EndRemapRequest(State *s)
1060{
1061 TxnDbg(dbg_ctl_http_trans, "START HttpTransact::EndRemapRequest");
1062
1063 HTTPHdr *incoming_request = &s->hdr_info.client_request;
1064 int method = incoming_request->method_get_wksidx();
1065 int host_len;
1066 const char *host = incoming_request->host_get(&host_len);
1067 TxnDbg(dbg_ctl_http_trans, "EndRemapRequest host is %.*s", host_len, host);
1068 if (s->state_machine->get_ua_txn()) {
1069 s->state_machine->get_ua_txn()->set_default_inactivity_timeout(HRTIME_SECONDS(s->txn_conf->default_inactivity_timeout));
1070 }
1071
1072 // Setting enable_redirection according to HttpConfig (master or overridable). We
1073 // defer this as late as possible, to allow plugins to modify the overridable
1074 // configurations (e.g. conf_remap.so). We intentionally only modify this if
1075 // the configuration says so.
1076 s->state_machine->enable_redirection = (s->txn_conf->number_of_redirections > 0);
1077
1078 ////////////////////////////////////////////////////////////////
1079 // if we got back a URL to redirect to, vector the user there //
1080 ////////////////////////////////////////////////////////////////
1081 if (s->remap_redirect != nullptr) {
1082 SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
1083 const char *error_body_type;
1084 switch (s->http_return_code) {
1085 case HTTP_STATUS_MOVED_PERMANENTLY:
1086 case HTTP_STATUS_PERMANENT_REDIRECT:
1087 case HTTP_STATUS_SEE_OTHER:
1088 case HTTP_STATUS_USE_PROXY:
1089 error_body_type = "redirect#moved_permanently";
1090 break;
1091 case HTTP_STATUS_MOVED_TEMPORARILY:
1092 case HTTP_STATUS_TEMPORARY_REDIRECT:
1093 error_body_type = "redirect#moved_temporarily";
1094 break;
1095 default:
1096 if (HTTP_STATUS_NONE == s->http_return_code) {
1097 s->http_return_code = HTTP_STATUS_MOVED_TEMPORARILY;
1098 Warning("Changed status code from '0' to '%d'.", s->http_return_code);
1099 } else {
1100 Warning("Using invalid status code for redirect '%d'. Building a response for a temporary redirect.", s->http_return_code);
1101 }
1102 error_body_type = "redirect#moved_temporarily";
1103 }
1104 build_error_response(s, s->http_return_code, "Redirect", error_body_type);
1105 ats_free(s->remap_redirect);
1106 s->reverse_proxy = false;
1107 goto done;
1108 }
1109 /////////////////////////////////////////////////////
1110 // Quick HTTP filtering (primary key: http method) //
1111 /////////////////////////////////////////////////////
1112 process_quick_http_filter(s, method);
1113 /////////////////////////////////////////////////////////////////////////
1114 // We must close this connection if client_connection_enabled == false //
1115 /////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 15

ats_freeFunction · 0.85
obj_describeFunction · 0.85
incrementFunction · 0.85
method_get_wksidxMethod · 0.80
get_ua_txnMethod · 0.80
is_target_in_urlMethod · 0.80
host_getMethod · 0.45
value_setMethod · 0.45
set_active_timeoutMethod · 0.45

Tested by

no test coverage detected