rack-client 0.3.1.pre.i → 0.3.1.pre.j

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,7 @@ module Rack
45
45
  env.update 'SCRIPT_NAME' => ''
46
46
  env.update 'QUERY_STRING' => uri.query.to_s
47
47
 
48
- input = body.respond_to?(:each) ? body : StringIO.new(body.to_s)
48
+ input = ensure_acceptable_input(body)
49
49
  errors = StringIO.new
50
50
 
51
51
  [ input, errors ].each do |io|
@@ -64,6 +64,21 @@ module Rack
64
64
 
65
65
  env
66
66
  end
67
+
68
+ def ensure_acceptable_input(body)
69
+ if %w[gets each read rewind].all? {|m| body.respond_to?(m.to_sym) }
70
+ body
71
+ elsif body.respond_to?(:each)
72
+ input = StringIO.new
73
+ body.each {|chunk| input << chunk }
74
+ input.rewind
75
+ input
76
+ else
77
+ input = StringIO.new(body.to_s)
78
+ input.rewind
79
+ input
80
+ end
81
+ end
67
82
  end
68
83
  end
69
84
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Client
3
- VERSION = "0.3.1.pre.i"
3
+ VERSION = "0.3.1.pre.j"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923832060
4
+ hash: 1923832061
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 1
10
10
  - pre
11
- - i
12
- version: 0.3.1.pre.i
11
+ - j
12
+ version: 0.3.1.pre.j
13
13
  platform: ruby
14
14
  authors:
15
15
  - Tim Carey-Smith
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-04-28 00:00:00 -07:00
20
+ date: 2011-05-06 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency