Attempt to compress the request body using the modeled encodings.
(config, request_dict, operation_model)
| 29 | |
| 30 | |
| 31 | def maybe_compress_request(config, request_dict, operation_model): |
| 32 | """Attempt to compress the request body using the modeled encodings.""" |
| 33 | if _should_compress_request(config, request_dict, operation_model): |
| 34 | for encoding in operation_model.request_compression['encodings']: |
| 35 | encoder = COMPRESSION_MAPPING.get(encoding) |
| 36 | if encoder is not None: |
| 37 | logger.debug('Compressing request with %s encoding.', encoding) |
| 38 | request_dict['body'] = encoder(request_dict['body']) |
| 39 | _set_compression_header(request_dict['headers'], encoding) |
| 40 | return |
| 41 | else: |
| 42 | logger.debug('Unsupported compression encoding: %s', encoding) |
| 43 | |
| 44 | |
| 45 | def _should_compress_request(config, request_dict, operation_model): |