mongrel2 0.25.0.pre.285 → 0.25.0.pre.288
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.tar.gz.sig +0 -0
- data/lib/mongrel2.rb +1 -1
- data/lib/mongrel2/httprequest.rb +0 -4
- data/lib/mongrel2/request.rb +9 -1
- data/lib/mongrel2/response.rb +3 -3
- data/spec/mongrel2/httprequest_spec.rb +0 -6
- data/spec/mongrel2/request_spec.rb +12 -0
- data/spec/mongrel2/response_spec.rb +8 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/mongrel2.rb
CHANGED
data/lib/mongrel2/httprequest.rb
CHANGED
|
@@ -32,10 +32,6 @@ class Mongrel2::HTTPRequest < Mongrel2::Request
|
|
|
32
32
|
### I N S T A N C E M E T H O D S
|
|
33
33
|
#################################################################
|
|
34
34
|
|
|
35
|
-
# Allow the entity body of the request to be modified
|
|
36
|
-
attr_writer :body
|
|
37
|
-
|
|
38
|
-
|
|
39
35
|
### Return +true+ if the request is an HTTP/1.1 request and its
|
|
40
36
|
### 'Connection' header indicates that the connection should stay
|
|
41
37
|
### open.
|
data/lib/mongrel2/request.rb
CHANGED
|
@@ -141,13 +141,21 @@ class Mongrel2::Request
|
|
|
141
141
|
attr_reader :headers
|
|
142
142
|
alias_method :header, :headers
|
|
143
143
|
|
|
144
|
-
# The request body data, if there is any, as an IO object
|
|
144
|
+
# The request body data, if there is any, as an IO(ish) object
|
|
145
145
|
attr_reader :body
|
|
146
146
|
|
|
147
147
|
# The raw request content, if the request was parsed from mongrel2
|
|
148
148
|
attr_reader :raw
|
|
149
149
|
|
|
150
150
|
|
|
151
|
+
### Set the request's entity body to +newbody+. If +newbody+ is a String-ish object
|
|
152
|
+
### (i.e., it responds to #to_str), it will be wrapped in a StringIO in 'r+' mode).
|
|
153
|
+
def body=( newbody )
|
|
154
|
+
newbody = StringIO.new( newbody, 'a+' ) if newbody.respond_to?( :to_str )
|
|
155
|
+
@body = newbody
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
151
159
|
### Create a Mongrel2::Response that will respond to the same server/connection as
|
|
152
160
|
### the receiver. If you wish your specialized Request class to have a corresponding
|
|
153
161
|
### response type, you can override the Mongrel2::Request.response_class method
|
data/lib/mongrel2/response.rb
CHANGED
|
@@ -64,10 +64,10 @@ class Mongrel2::Response
|
|
|
64
64
|
attr_accessor :chunksize
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
### Set the response body to +newbody+. If +newbody+ is
|
|
68
|
-
###
|
|
67
|
+
### Set the response's entity body to +newbody+. If +newbody+ is a String-ish object
|
|
68
|
+
### (i.e., it responds to #to_str), it will be wrapped in a StringIO in 'a+' mode).
|
|
69
69
|
def body=( newbody )
|
|
70
|
-
newbody = StringIO.new( newbody, 'a+' )
|
|
70
|
+
newbody = StringIO.new( newbody, 'a+' ) if newbody.respond_to?( :to_str )
|
|
71
71
|
@body = newbody
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -79,12 +79,6 @@ describe Mongrel2::HTTPRequest do
|
|
|
79
79
|
@req.should be_keepalive()
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
it "allows the request body to be rewritten" do
|
|
83
|
-
@req.body = 'something else'
|
|
84
|
-
@req.body.should == 'something else'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
82
|
describe "header convenience methods" do
|
|
89
83
|
|
|
90
84
|
before( :each ) do
|
|
@@ -108,6 +108,18 @@ describe Mongrel2::Request do
|
|
|
108
108
|
@req.response.should equal( @req.response )
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
it "allows the entity body to be replaced by assigning a String" do
|
|
112
|
+
@req.body = 'something else'
|
|
113
|
+
@req.body.should be_a( StringIO )
|
|
114
|
+
@req.body.string.should == 'something else'
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "doesn't try to wrap non-stringish entity body replacements in a StringIO" do
|
|
118
|
+
testobj = Object.new
|
|
119
|
+
@req.body = testobj
|
|
120
|
+
@req.body.should be( testobj )
|
|
121
|
+
end
|
|
122
|
+
|
|
111
123
|
end
|
|
112
124
|
|
|
113
125
|
|
|
@@ -61,13 +61,20 @@ describe Mongrel2::Response do
|
|
|
61
61
|
expect {|b| response.each_chunk(&b) }.to yield_with_args( 'the body' )
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
it "wraps
|
|
64
|
+
it "wraps stringifiable bodies set via the #body= accessor in a StringIO" do
|
|
65
65
|
response = Mongrel2::Response.new( TEST_UUID, 8 )
|
|
66
66
|
response.body = 'a stringioed body'
|
|
67
67
|
response.body.should be_a( StringIO )
|
|
68
68
|
response.body.string.should == 'a stringioed body'
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
it "doesn't try to wrap non-stringfiable bodies in a StringIO" do
|
|
72
|
+
response = Mongrel2::Response.new( TEST_UUID, 8 )
|
|
73
|
+
testbody = Object.new
|
|
74
|
+
response.body = testbody
|
|
75
|
+
response.body.should be( testbody )
|
|
76
|
+
end
|
|
77
|
+
|
|
71
78
|
context "an instance with default values" do
|
|
72
79
|
|
|
73
80
|
before( :each ) do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongrel2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.25.0.pre.
|
|
4
|
+
version: 0.25.0.pre.288
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
|
36
36
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
|
37
37
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
|
38
38
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
|
39
|
-
date: 2012-06-
|
|
39
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
|
40
40
|
dependencies:
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: nokogiri
|
metadata.gz.sig
CHANGED
|
Binary file
|