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

Function client_accepts_compression

plugins/compress/compress.cc:802–903  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802static int
803client_accepts_compression(TSHttpTxn txnp, bool server, HostConfiguration *host_configuration, int *compress_type, int *algorithms)
804{
805 /* Server response header */
806 TSMBuffer bufp;
807 TSMLoc hdr_loc;
808
809 /* Client request header */
810 TSMBuffer cbuf;
811 TSMLoc chdr;
812 TSMLoc cfield;
813
814 const char *value;
815 int len;
816
817 if (server) {
818 if (TS_SUCCESS != TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc)) {
819 return 0;
820 }
821 } else {
822 if (TS_SUCCESS != TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc)) {
823 return 0;
824 }
825 }
826
827 if (TS_SUCCESS != TSHttpTxnClientReqGet(txnp, &cbuf, &chdr)) {
828 info("cound not get client request");
829 TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
830 return 0;
831 }
832
833 // check Partial Object is transformable
834 if (host_configuration->range_request_ctl() == RangeRequestCtrl::NO_COMPRESSION) {
835 // check Range header in client request
836 // CAVETE: some plugin (- e.g. cache_range_request) tweaks client headers
837 TSMLoc range_hdr_field = TSMimeHdrFieldFind(cbuf, chdr, TS_MIME_FIELD_RANGE, TS_MIME_LEN_RANGE);
838 if (range_hdr_field != TS_NULL_MLOC) {
839 debug("Range header found in the request and range_request is configured as no_compression");
840 TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
841 TSHandleMLocRelease(cbuf, chdr, range_hdr_field);
842 TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
843 return 0;
844 }
845
846 // check Content-Range header in (cached) server response
847 TSMLoc content_range_hdr_field = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_RANGE, TS_MIME_LEN_CONTENT_RANGE);
848 if (content_range_hdr_field != TS_NULL_MLOC) {
849 debug("Content-Range header found in the response and range_request is configured as no_compression");
850 TSHandleMLocRelease(bufp, hdr_loc, content_range_hdr_field);
851 TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
852 TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
853 return 0;
854 }
855 }
856
857 *algorithms = host_configuration->compression_algorithms();
858 cfield = TSMimeHdrFieldFind(cbuf, chdr, TS_MIME_FIELD_ACCEPT_ENCODING, TS_MIME_LEN_ACCEPT_ENCODING);
859 if (cfield != TS_NULL_MLOC) {

Callers 1

transformableFunction · 0.85

Calls 9

TSHttpTxnServerRespGetFunction · 0.85
TSHttpTxnCachedRespGetFunction · 0.85
TSHttpTxnClientReqGetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSMimeHdrFieldFindFunction · 0.85
range_request_ctlMethod · 0.80

Tested by

no test coverage detected