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

Method HandleApiErrorJump

src/proxy/http/HttpTransact.cc:1733–1771  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////// void HttpTransact::HandleApiErrorJump(State* s) Called after an API function indicates it wished to send an error to the user agent ///////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1731// error to the user agent
1732////////////////////////////////////////////////////////////////////////
1733void
1734HttpTransact::HandleApiErrorJump(State *s)
1735{
1736 TxnDbg(dbg_ctl_http_trans, "Entering HttpTransact::HandleApiErrorJump");
1737
1738 // since the READ_REQUEST_HDR_HOOK is processed before
1739 // we examine the request, returning TS_EVENT_ERROR will cause
1740 // the protocol in the via string to be "?" Set it here
1741 // since we know it has to be http
1742 // For CONNECT method, next_hop_scheme is NULL
1743 if (s->next_hop_scheme < 0) {
1744 s->next_hop_scheme = URL_WKSIDX_HTTP;
1745 }
1746 // The client response may not be empty in the
1747 // case the txn was reenabled in error by a plugin from hook SEND_RESPONSE_HDR.
1748 // build_response doesn't clean the header. So clean it up before.
1749 // Do fields_clear() instead of clear() to prevent memory leak
1750 if (s->hdr_info.client_response.valid()) {
1751 s->hdr_info.client_response.fields_clear();
1752 }
1753
1754 // Set the source to internal so chunking is handled correctly
1755 s->source = SOURCE_INTERNAL;
1756
1757 /**
1758 The API indicated an error. Lets use a >=400 error from the state (if one's set) or fallback to a
1759 generic HTTP/1.X 500 INKApi Error
1760 **/
1761 if (s->http_return_code && s->http_return_code >= HTTP_STATUS_BAD_REQUEST) {
1762 const char *reason = http_hdr_reason_lookup(s->http_return_code);
1763 ;
1764 build_response(s, &s->hdr_info.client_response, s->client_info.http_version, s->http_return_code, reason ? reason : "Error");
1765 } else {
1766 build_response(s, &s->hdr_info.client_response, s->client_info.http_version, HTTP_STATUS_INTERNAL_SERVER_ERROR, "INKApi Error");
1767 }
1768
1769 TRANSACT_RETURN(SM_ACTION_INTERNAL_CACHE_NOOP, nullptr);
1770 return;
1771}
1772
1773// PPDNSLookupAPICall does an API callout if a plugin set the response_action,
1774// then calls PPDNSLookup.

Callers

nothing calls this directly

Calls 3

http_hdr_reason_lookupFunction · 0.85
fields_clearMethod · 0.80
validMethod · 0.45

Tested by

no test coverage detected