Class: HTTPX::Transcoder::Multipart::Decoder

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/httpx/transcoder/multipart/decoder.rb,
sig/transcoder/multipart.rbs

Constant Summary collapse

CRLF =

Returns:

  • (String)
"\r\n"
BOUNDARY_RE =

Returns:

  • (Regexp)
/;\s*boundary=([^;]+)/i.freeze
MULTIPART_CONTENT_TYPE =

Returns:

  • (Regexp)
/Content-Type: (.*)#{CRLF}/ni.freeze
MULTIPART_CONTENT_DISPOSITION =

Returns:

  • (Regexp)
/Content-Disposition:.*;\s*name=(#{VALUE})/ni.freeze
MULTIPART_CONTENT_ID =

Returns:

  • (Regexp)
/Content-ID:\s*([^#{CRLF}]*)/ni.freeze
WINDOW_SIZE =

Returns:

  • (Integer)
2 << 14

Constants included from Utils

Utils::FILENAME_EXTENSION_REGEX, Utils::FILENAME_REGEX, Utils::TOKEN, Utils::URIParser, Utils::VALUE

Instance Method Summary collapse

Methods included from Utils

elapsed_time, get_filename, in_ractor?, now, parse_retry_after, to_uri

Instance Method Details

#call(response) ⇒ Hash[String, untyped]

Parameters:

Returns:

  • (Hash[String, untyped])

Raises:



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/httpx/transcoder/multipart/decoder.rb', line 44

def call(response, *)
  response.body.each do |chunk|
    @buffer << chunk

    parse
  end

  raise Error, "invalid or unsupported multipart format" unless @buffer.empty?

  @parts
end