Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4938,6 +4938,12 @@ HttpSM::do_http_server_open(bool raw)
}
}

// Check for self loop.
if (HttpTransact::will_this_request_self_loop(&t_state)) {
call_transact_and_set_next_state(HttpTransact::SelfLoop);
return;
}

// If this is not a raw connection, we try to get a session from the
// shared session pool. Raw connections are for SSLs tunnel and
// require a new connection
Expand Down
22 changes: 10 additions & 12 deletions proxy/http/HttpTransact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,16 @@ HttpTransact::Forbidden(State *s)
TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
}

void
HttpTransact::SelfLoop(State *s)
{
TxnDebug("http_trans", "[Loop]"
"Request will selfloop.");
bootstrap_state_variables_from_request(s, &s->hdr_info.client_request);
build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Direct self loop detected", "request#cycle_detected");
TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
}

void
HttpTransact::TooEarly(State *s)
{
Expand Down Expand Up @@ -1856,17 +1866,6 @@ HttpTransact::OSDNSLookup(State *s)
TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
}

// detect whether we are about to self loop. the client may have
// specified the proxy as the origin server (badness).
// Check if this procedure is already done - YTS Team, yamsat
if (!s->request_will_not_selfloop) {
if (will_this_request_self_loop(s)) {
TxnDebug("http_trans", "[OSDNSLookup] request will selfloop - bailing out");
SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
}
}

if (!s->dns_info.lookup_success) {
// maybe the name can be expanded (e.g cnn -> www.cnn.com)
HostNameExpansionError_t host_name_expansion = try_to_expand_host_name(s);
Expand Down Expand Up @@ -6640,7 +6639,6 @@ HttpTransact::will_this_request_self_loop(State *s)
via_field = via_field->m_next_dup;
}
}
s->request_will_not_selfloop = true;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion proxy/http/HttpTransact.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ class HttpTransact
bool force_dns = false;
MgmtByte cache_open_write_fail_action = 0;
bool is_revalidation_necessary = false; // Added to check if revalidation is necessary - YTS Team, yamsat
bool request_will_not_selfloop = false; // To determine if process done - YTS Team, yamsat
ConnectionAttributes client_info;
ConnectionAttributes parent_info;
ConnectionAttributes server_info;
Expand Down Expand Up @@ -939,6 +938,7 @@ class HttpTransact
static void BadRequest(State *s);
static void Forbidden(State *s);
static void TooEarly(State *s);
static void SelfLoop(State *s);
static void PostActiveTimeoutResponse(State *s);
static void PostInactiveTimeoutResponse(State *s);
static void DecideCacheLookup(State *s);
Expand Down