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

Function handle_request

plugins/compress/compress.cc:1090–1128  ·  view source on GitHub ↗

* This handles a compress request * 1. Reads the client request header * 2. For global plugin, get host configuration from global config * For remap plugin, get host configuration from configs populated through remap * 3. Check for Accept-Encoding header * 4. Check for Range header * 5. Schedules TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK and TS_HTTP_TXN_CLOSE_HOOK for * further processing *

Source from the content-addressed store, hash-verified

1088 * further processing
1089 */
1090static void
1091handle_request(TSHttpTxn txnp, Configuration *config)
1092{
1093 TSMBuffer req_buf;
1094 TSMLoc req_loc;
1095 HostConfiguration *hc;
1096
1097 if (TSHttpTxnClientReqGet(txnp, &req_buf, &req_loc) == TS_SUCCESS) {
1098 if (config == nullptr) {
1099 hc = find_host_configuration(txnp, req_buf, req_loc, nullptr);
1100 } else {
1101 hc = find_host_configuration(txnp, req_buf, req_loc, config);
1102 }
1103 bool allowed = false;
1104
1105 if (hc->enabled()) {
1106 if (hc->has_allows()) {
1107 int url_len;
1108 char *url = TSHttpTxnEffectiveUrlStringGet(txnp, &url_len);
1109 allowed = hc->is_url_allowed(url, url_len);
1110 TSfree(url);
1111 } else {
1112 allowed = true;
1113 }
1114 }
1115 if (allowed) {
1116 TSCont transform_contp = TSContCreate(transform_plugin, nullptr);
1117
1118 TSContDataSet(transform_contp, (void *)hc);
1119
1120 info("Kicking off compress plugin for request");
1121 normalize_accept_encoding(txnp, req_buf, req_loc);
1122 handle_range_request(req_buf, req_loc, hc);
1123 TSHttpTxnHookAdd(txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, transform_contp);
1124 TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, transform_contp); // To release the config
1125 }
1126 TSHandleMLocRelease(req_buf, TS_NULL_MLOC, req_loc);
1127 }
1128}
1129
1130static int
1131transform_global_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)

Callers 2

transform_global_pluginFunction · 0.85
TSRemapDoRemapFunction · 0.85

Calls 13

TSHttpTxnClientReqGetFunction · 0.85
find_host_configurationFunction · 0.85
TSfreeFunction · 0.85
TSContCreateFunction · 0.85
TSContDataSetFunction · 0.85
handle_range_requestFunction · 0.85
TSHttpTxnHookAddFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
has_allowsMethod · 0.80
is_url_allowedMethod · 0.80

Tested by

no test coverage detected