Sha256: 36e47103991817c5e763161e7c2c15a2f43275b9d49862a5137f518c567ed92d
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module HTTPX module Plugins module Compression module Brotli class << self def load_dependencies(klass) klass.plugin(:compression) require "brotli" end def configure(klass) klass.default_options.encodings.register "br", self end end module Deflater module_function def deflate(raw, buffer, chunk_size:) while (chunk = raw.read(chunk_size)) compressed = ::Brotli.deflate(chunk) buffer << compressed yield compressed if block_given? end end end class Inflater def initialize(bytesize) @bytesize = bytesize end def inflate(chunk) ::Brotli.inflate(chunk) end end module_function def deflater Deflater end def inflater(bytesize) Inflater.new(bytesize) end end end register_plugin :"compression/brotli", Compression::Brotli end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
httpx-0.13.2 | lib/httpx/plugins/compression/brotli.rb |
httpx-0.13.1 | lib/httpx/plugins/compression/brotli.rb |
httpx-0.13.0 | lib/httpx/plugins/compression/brotli.rb |