Sha256: d2fcec599016e04b73ef2764d869bfc10e5ca474ce69ac56adc7c7abff5130f4
Contents?: true
Size: 1.05 KB
Versions: 20
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module HTTPX module Plugins module Brotli class Deflater < Transcoder::Deflater def deflate(chunk) return unless chunk ::Brotli.deflate(chunk) end end module RequestBodyClassMethods def initialize_deflater_body(body, encoding) return Brotli.encode(body) if encoding == "br" super end end module ResponseBodyClassMethods def initialize_inflater_by_encoding(encoding, response, **kwargs) return Brotli.decode(response, **kwargs) if encoding == "br" super end end module_function def load_dependencies(*) require "brotli" end def self.extra_options(options) options.merge(supported_compression_formats: %w[br] + options.supported_compression_formats) end def encode(body) Deflater.new(body) end def decode(_response, **) ::Brotli.method(:inflate) end end register_plugin :brotli, Brotli end end
Version data entries
20 entries across 20 versions & 1 rubygems