@@ -103,8 +103,8 @@ handle_range_request(TSMBuffer req_buf, TSMLoc req_loc, HostConfiguration *hc)
103103 debug (" Both of Accept-Encoding and Range header are found in the request" );
104104
105105 switch (hc->range_request_ctl ()) {
106- case RangeRequestCtrl::IGNORE_RANGE : {
107- debug (" Remove the Range header by ignore -range config" );
106+ case RangeRequestCtrl::REMOVE_RANGE : {
107+ debug (" Remove the Range header by remove -range config" );
108108 while (range_hdr_field) {
109109 TSMLoc next_dup = TSMimeHdrFieldNextDup (req_buf, req_loc, range_hdr_field);
110110 TSMimeHdrFieldDestroy (req_buf, req_loc, range_hdr_field);
@@ -113,8 +113,8 @@ handle_range_request(TSMBuffer req_buf, TSMLoc req_loc, HostConfiguration *hc)
113113 }
114114 break ;
115115 }
116- case RangeRequestCtrl::NO_COMPRESSION : {
117- debug (" Remove the Accept-Encoding header by no-compression config" );
116+ case RangeRequestCtrl::REMOVE_ACCEPT_ENCODING : {
117+ debug (" Remove the Accept-Encoding header by remove-accept-encoding config" );
118118 while (accept_encoding_hdr_field) {
119119 TSMLoc next_dup = TSMimeHdrFieldNextDup (req_buf, req_loc, accept_encoding_hdr_field);
120120 TSMimeHdrFieldDestroy (req_buf, req_loc, accept_encoding_hdr_field);
@@ -123,6 +123,10 @@ handle_range_request(TSMBuffer req_buf, TSMLoc req_loc, HostConfiguration *hc)
123123 }
124124 break ;
125125 }
126+ case RangeRequestCtrl::NO_COMPRESSION:
127+ // Do NOT touch header - this config is referred by `transformable()` function
128+ debug (" no header modification by no-compression config" );
129+ break ;
126130 case RangeRequestCtrl::NONE:
127131 [[fallthrough]];
128132 default :
@@ -733,6 +737,33 @@ transformable(TSHttpTxn txnp, bool server, HostConfiguration *host_configuration
733737 return 0 ;
734738 }
735739
740+ // check Partial Object is transformable
741+ if (host_configuration->range_request_ctl () == RangeRequestCtrl::NO_COMPRESSION) {
742+ // check Range header in client request
743+ // CAVETE: some plugin (- e.g. cache_range_request) tweaks client headers
744+ TSMLoc range_hdr_field = TSMimeHdrFieldFind (cbuf, chdr, TS_MIME_FIELD_RANGE, TS_MIME_LEN_RANGE);
745+ if (range_hdr_field != TS_NULL_MLOC) {
746+ debug (" Range header found in the request and range_request is configured as no_compression" );
747+ TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
748+ TSHandleMLocRelease (cbuf, chdr, range_hdr_field);
749+ TSHandleMLocRelease (cbuf, TS_NULL_MLOC, chdr);
750+ return 0 ;
751+ }
752+
753+ // check Content-Range header in (cached) server response
754+ TSMLoc content_range_hdr_field = TSMimeHdrFieldFind (bufp, hdr_loc, TS_MIME_FIELD_CONTENT_RANGE, TS_MIME_LEN_CONTENT_RANGE);
755+ if (content_range_hdr_field != TS_NULL_MLOC) {
756+ debug (" Content-Range header found in the response and range_request is configured as no_compression" );
757+ TSHandleMLocRelease (bufp, hdr_loc, content_range_hdr_field);
758+ TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
759+ TSHandleMLocRelease (cbuf, TS_NULL_MLOC, chdr);
760+ return 0 ;
761+ }
762+
763+ TSHandleMLocRelease (bufp, hdr_loc, content_range_hdr_field);
764+ TSHandleMLocRelease (cbuf, chdr, range_hdr_field);
765+ }
766+
736767 // the only compressible method is currently GET.
737768 int method_length;
738769 const char *method = TSHttpHdrMethodGet (cbuf, chdr, &method_length);
@@ -966,8 +997,8 @@ transform_plugin(TSCont contp, TSEvent event, void *edata)
966997 * 1. Reads the client request header
967998 * 2. For global plugin, get host configuration from global config
968999 * For remap plugin, get host configuration from configs populated through remap
969- * 3. Check for Accept encoding
970- * 4. Remove Range header
1000+ * 3. Check for Accept-Encoding header
1001+ * 4. Check for Range header
9711002 * 5. Schedules TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK and TS_HTTP_TXN_CLOSE_HOOK for
9721003 * further processing
9731004 */
0 commit comments