Sha256: 5f2bcfe59107cd0c7ede5a7fc3d08420aeb4484b65591a4dae66f6580e78c4be
Contents?: true
Size: 806 Bytes
Versions: 2
Compression:
Stored size: 806 Bytes
Contents
require 'backlog_kit/response/middleware' require 'backlog_kit/resource_file' module BacklogKit class Response class FileParser < BacklogKit::Response::Middleware def on_complete(env) super env.body = BacklogKit::ResourceFile.new(decoded_filename, body) if file? end private def file? !(no_content? || json?) end def decoded_filename match_data = content_disposition.match(/=(.*)''(.+)\z/) encode = match_data[1] filename = match_data[2] return filename if encode.empty? URI.decode_www_form_component(filename, encode) end def content_disposition headers['content-disposition'] end end Faraday::Response.register_middleware(file_parser: FileParser) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
backlog_kit-0.19.0 | lib/backlog_kit/response/file_parser.rb |
backlog_kit-0.18.0 | lib/backlog_kit/response/file_parser.rb |