francois-rest-client 1.1.5 → 1.1.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
@@ -64,6 +64,7 @@ module RestClient
64
64
 
65
65
  def inspect
66
66
  to_s.inspect
67
+ @stream.seek(0)
67
68
  end
68
69
  end
69
70
 
@@ -115,7 +116,7 @@ module RestClient
115
116
  def create_file_field(s, k, v)
116
117
  begin
117
118
  s.write("Content-Disposition: multipart/form-data; name=\"#{k}\"; filename=\"#{File.basename(v.path)}\"#{EOL}")
118
- s.write("Content-Type: #{mime_for(v.path)}#{EOL}")
119
+ s.write("Content-Type: #{v.respond_to?(:content_type) ? v.content_type : mime_for(v.path)}#{EOL}")
119
120
  s.write(EOL)
120
121
  while data = v.read(8124)
121
122
  s.write(data)
@@ -45,6 +45,20 @@ Content-Type: image/jpeg\r
45
45
  \r
46
46
  #{IO.read(f.path)}\r
47
47
  --#{m.boundary}--\r
48
+ EOS
49
+ end
50
+
51
+ it "should detect content type if tempfile responds to content_type" do
52
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
53
+ f.instance_eval "def content_type; 'text/plain'; end"
54
+ m = RestClient::Payload::Multipart.new({:foo => f})
55
+ m.to_s.should == <<-EOS
56
+ --#{m.boundary}\r
57
+ Content-Disposition: multipart/form-data; name="foo"; filename="master_shake.jpg"\r
58
+ Content-Type: text/plain\r
59
+ \r
60
+ #{IO.read(f.path)}\r
61
+ --#{m.boundary}--\r
48
62
  EOS
49
63
  end
50
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: francois-rest-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wiggins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-09-21 00:00:00 -07:00
13
13
  default_executable: restclient
14
14
  dependencies: []
15
15