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

Method handleIfRedirect

src/proxy/http/HttpTransact.cc:1488–1512  ·  view source on GitHub ↗

This function is supposed to figure out if this transaction is susceptible to a redirection as specified by remap.config

Source from the content-addressed store, hash-verified

1486// This function is supposed to figure out if this transaction is
1487// susceptible to a redirection as specified by remap.config
1488bool
1489HttpTransact::handleIfRedirect(State *s)
1490{
1491 int answer;
1492 URL redirect_url;
1493
1494 answer = request_url_remap_redirect(&s->hdr_info.client_request, &redirect_url, s->state_machine->m_remap);
1495 if ((answer == PERMANENT_REDIRECT) || (answer == TEMPORARY_REDIRECT)) {
1496 s->remap_redirect = redirect_url.string_get_ref(nullptr);
1497 if (answer == TEMPORARY_REDIRECT) {
1498 if ((s->client_info).http_version == HTTP_1_1) {
1499 build_error_response(s, HTTP_STATUS_TEMPORARY_REDIRECT, "Redirect", "redirect#moved_temporarily");
1500 } else {
1501 build_error_response(s, HTTP_STATUS_MOVED_TEMPORARILY, "Redirect", "redirect#moved_temporarily");
1502 }
1503 } else {
1504 build_error_response(s, HTTP_STATUS_MOVED_PERMANENTLY, "Redirect", "redirect#moved_permanently");
1505 }
1506 s->remap_redirect = nullptr;
1507 redirect_url.destroy();
1508 return true;
1509 }
1510
1511 return false;
1512}
1513
1514void
1515HttpTransact::HandleRequest(State *s)

Callers

nothing calls this directly

Calls 3

string_get_refMethod · 0.80
destroyMethod · 0.45

Tested by

no test coverage detected