Sha256: c8c7e9fe3396733fca3dd74ba77dafc61c15ba32d9b9f12c7ba2cb5ce08337c6
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
module ChatWork class Multipart < ::Faraday::Multipart::Middleware def create_multipart(env, params) original_body = super(env, params) # replace from Faraday::Parts::EpiloguePart to ChatWork::Multipart::EpiloguePart parts = original_body.instance_variable_get(:@parts) parts.pop parts << EpiloguePart.new(env.request.boundary) new_body = ::Faraday::CompositeReadIO.new(*parts) env.request_headers[Faraday::Env::ContentLength] = new_body.length.to_s new_body end end class EpiloguePart < ::Faraday::Parts::EpiloguePart def initialize(boundary) # rubocop:disable Lint/MissingSuper # NOTE: ChatWork doesn't accepts ending "\r\n\r\n" of payload... # @part = "--#{boundary}--\r\n\r\n" @part = "--#{boundary}--\r\n" @io = StringIO.new(@part) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chatwork-1.0.1 | lib/chatwork/multipart.rb |