mongrel2 0.25.0.pre.285 → 0.25.0.pre.288

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -23,7 +23,7 @@ module Mongrel2
23
23
  VERSION = '0.25.0'
24
24
 
25
25
  # Version-control revision constant
26
- REVISION = %q$Revision: 928743f397cc $
26
+ REVISION = %q$Revision: 893e0493be04 $
27
27
 
28
28
 
29
29
  require 'mongrel2/constants'
@@ -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.
@@ -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
@@ -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 not a IO-like object (i.e., it
68
- ### doesn't respond to #eof?, it will be wrapped in a StringIO in 'a+' mode).
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+' ) unless newbody.respond_to?( :eof? )
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 non-IO bodies set via the #body= accessor in a StringIO" do
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.285
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-20 00:00:00.000000000 Z
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