savonrb / savon-multipart Goto Github PK
View Code? Open in Web Editor NEWHeavy metal Ruby SOAP client with multipart support
License: MIT License
Heavy metal Ruby SOAP client with multipart support
License: MIT License
I ran into an issue with savon-multipart and binary files that were not attachments (they appear in the mail#part body) as described here: https://stackoverflow.com/questions/43073477/ruby-writing-binary-string-7zip-to-file-file-gets-corrupted/43122970
Could savon-multipart be updated to depend on a version of Mail gem that fixes this issue?
Currently I am using this workaround, but I think there should be a better way to fix this.
module Savon
module SOAP
class Response
def soap_fault
@soap_fault ||= Fault.new(HTTPI::Response.new(http.code, http.headers, to_xml))
end
end
end
end
The following is the current state of Savon::Soap::Response#to_xml:
# Overwrite to work with multipart response.
def to_xml
if multipart?
parts.first.body.encoded # we just assume the first part is the XML
else
http.body
end
end
It seems that "parts.first.body.encoded" is a typo and should be "parts.first.body.decoded" instead. This is the only way I could get it to work properly.
Cloned from Savon issue 682. savonrb/savon#682
pulling from https://github.com/savonrb/savon-multipart/blob/master/spec/savon/soap/response_spec.rb#L9
I created this that forced the response into a multipart class, which worked.
globals = {
:multipart => true,
:raise_errors => true,
:convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}
}
response = Savon::Multipart::Response.new(response.http, globals, {})
response.hash
Any ideas why this doesn't happen automatically, or if I'm missing something?
Thanks!
A good workaround might be to consider an option that just allows the user to force the response to be parsed as multipart, or possibly improving the regex to allow for more varied types of multipart headers.
I'm confused with the Readme saying "use branch 'savon2' with when running savon >= 2.0 ". I just did, but it didn't work with latest savon version (as of gemspec dependencu on savon 2.1).
Instead latest savon-multipart gem just worked fine with latest savon
So is Readme outdated and the note about savon 2 should be removed??
I am updating Rails 5 app to Rails 6 and facing gems versions conflicts:
Bundler could not find compatible versions for gem "mail":
In snapshot (Gemfile.lock):
mail (= 2.7.1)
In Gemfile:
rails (= 6.1.4) was resolved to 6.1.4, which depends on
actionmailbox (= 6.1.4) was resolved to 6.1.4, which depends on
mail (>= 2.7.1)
savon-multipart (= 2.1.1) was resolved to 2.1.1, which depends on
mail (~> 2.5.4)
Any advice? This gem has no updates for 2 years. Does savon still need it or maybe it support multipart messages without this gem now?
In order to make things more responsive, I propose we pick a new CI.
Perhaps GitHub Actions?
Please allow more flexible dependency than :
s.add_dependency "mail", "2.5.3"
Hello,
I work with this gem sind over a year and it works great.
But after I updated Savon from 2.12.1 to 2.13.1, it is not working anymore.
I got in the XML only:
<xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\" href=\"cid:[email protected]\"/>
I use the master branch of this gem (It was because of some problems last year, maybe I will try the newest version).
But is this an issue with my code or the savon version?
My response header contains
Content-Type:
- Multipart/Related;
So, the Multipart is with a capital M. Is it possible to change the regex so it is case insensitive?
The regex is on line 33:
https://github.com/savonrb/savon-multipart/blob/master/lib/savon/multipart/response.rb#L33
I think it is to small to make a pull request, but let me know if you prefer one!
Steven
No one has asked for multipart support in Sekken, but it might be interesting to consider adding it as a core function.
I see that the project is no longer on Rubygems: http://rubygems.org/gems/savon-multipart
Is it still being maintained?
Currently the \n
char gets replaced with \r\n
in binary parts:
My current workaround is:
module Mail
class Message
# Avoids calling {String#to_crlf} on binary parts.
def raw_source=(value)
if value.include?("Content-Transfer-Encoding: binary")
@raw_source = value
else
@raw_source = value.to_crlf
end
end
end
end
You can reproduce this with a PDF:
--uuid:f2520735-6098-4586-93f3-019733fc1404+id=4
Content-ID: <http://tempuri.org/1/634746078367623835>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream
%PDF-1.3
....
Should I open a ticket for the mail
gem?
Hello,
this gem is only for multipart responses rigth? any hint for doing multipart requests?
thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.