fredo 0.1.4 → 0.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 +1 -1
- data/fredo.gemspec +1 -1
- data/lib/fredo/ext/net_http.rb +5 -3
- data/spec/fredo_spec.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/fredo.gemspec
CHANGED
data/lib/fredo/ext/net_http.rb
CHANGED
@@ -41,6 +41,9 @@ module Net #:nodoc: all
|
|
41
41
|
case request_body
|
42
42
|
when nil then body = StringIO.new
|
43
43
|
when String then body = StringIO.new(body)
|
44
|
+
when File then body
|
45
|
+
else
|
46
|
+
body = StringIO.new(body.to_s)
|
44
47
|
end
|
45
48
|
|
46
49
|
uri = URI.parse(request.path)
|
@@ -64,7 +67,6 @@ module Net #:nodoc: all
|
|
64
67
|
# @socket = Net::HTTP.socket_type.new
|
65
68
|
# Perform the request
|
66
69
|
status, header, body = Fredo.call(rack_env)
|
67
|
-
# body = body.to_s # should write to rocket or do something fancier?
|
68
70
|
|
69
71
|
response = Net::HTTPResponse.send(:response_class, "#{status}").new("1.0", "#{status}", body)
|
70
72
|
response.instance_variable_set(:@body, body)
|
@@ -72,8 +74,8 @@ module Net #:nodoc: all
|
|
72
74
|
response.instance_variable_set(:@read, true)
|
73
75
|
|
74
76
|
def response.read_body(*args, &block)
|
75
|
-
yield @body if block_given?
|
76
|
-
@body
|
77
|
+
yield @body.join("\n") if block_given?
|
78
|
+
@body.join("\n")
|
77
79
|
end
|
78
80
|
|
79
81
|
yield response if block_given?
|
data/spec/fredo_spec.rb
CHANGED
@@ -53,7 +53,7 @@ describe Fredo do
|
|
53
53
|
|
54
54
|
url = URI.parse 'http://postyourthoughts.com'
|
55
55
|
http = Net::HTTP.new(url.host)
|
56
|
-
http.post('/', 'query=foo', 'content-type' => 'text/plain').body.should eql(
|
56
|
+
http.post('/', 'query=foo', 'content-type' => 'text/plain').body.should eql(body)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|