* 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 *
| 1088 | * further processing |
| 1089 | */ |
| 1090 | static void |
| 1091 | handle_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 | |
| 1130 | static int |
| 1131 | transform_global_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata) |
no test coverage detected