httmultiparty 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 if @header.nil?
5
+ super
6
+ set_headers_for_body
6
7
  end
7
8
 
8
9
  def body=(value)
9
- boundary = DEFAULT_BOUNDARY
10
- parts = value.map {|(k,v)| Parts::Part.new(boundary, k, v)}
11
- parts << Parts::EpiloguePart.new(boundary)
12
- self.set_content_type("multipart/form-data", { "boundary" => boundary })
13
- self.content_length = parts.inject(0) {|sum,i| sum + i.length }
14
- self.body_stream = CompositeReadIO.new(*parts.map { |part| part.to_io })
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
@@ -1,3 +1,3 @@
1
1
  module HTTMultiParty
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.4'
3
3
  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.2
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-01 00:00:00 +02:00
13
+ date: 2011-08-16 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency