httmultiparty 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/httmultiparty/multipartable.rb +19 -7
- data/lib/httmultiparty/version.rb +1 -1
- metadata +2 -2
@@ -2,15 +2,27 @@ module HTTMultiParty::Multipartable
|
|
2
2
|
DEFAULT_BOUNDARY = "-----------RubyMultipartPost"
|
3
3
|
# prevent reinitialization of headers
|
4
4
|
def initialize_http_header(initheader)
|
5
|
-
super
|
5
|
+
super
|
6
|
+
set_headers_for_body
|
6
7
|
end
|
7
8
|
|
8
9
|
def body=(value)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
@body_parts = value.map {|(k,v)| Parts::Part.new(boundary, k, v)}
|
11
|
+
@body_parts << Parts::EpiloguePart.new(boundary)
|
12
|
+
set_headers_for_body
|
13
|
+
end
|
14
|
+
|
15
|
+
def boundary
|
16
|
+
DEFAULT_BOUNDARY
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def set_headers_for_body
|
22
|
+
if @body_parts
|
23
|
+
self.set_content_type("multipart/form-data", { "boundary" => boundary })
|
24
|
+
self.content_length = @body_parts.inject(0) {|sum,i| sum + i.length }
|
25
|
+
self.body_stream = CompositeReadIO.new(*@body_parts.map { |part| part.to_io })
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: httmultiparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Johannes Wagener
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-16 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|