public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
* Fix uploading hanging bug when body is moved to a tempfile,
  also delete the tempfile properly upon completion, fixes #25
macournoyer (author)
Tue Jan 29 19:28:24 -0800 2008
commit  dc607a67b9931ab6f1d9026e24e3311b49466c2f
tree    df2605e6c4560303e62713d7f01283301a58c6f6
parent  d019105fe46b732114e3f0bf2017ab294ac9e105
...
1
2
 
 
 
3
4
5
...
1
 
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 == 0.6.2 Rambo release
0
- * thin restart now sends HUP signals rather then stopping & starting.
0
+ * Fix uploading hanging bug when body is moved to a tempfile,
0
+ also delete the tempfile properly upon completion, fixes #25
0
+ * 'thin restart' now sends HUP signals rather then stopping & starting, closes #17
0
  * HUP signal now launches a new process with the same options.
0
  * Add PID and more info from the last request to the Stats adapter
0
    mostly taken from Rack::ShowException.
...
92
93
94
95
 
96
97
98
99
100
 
101
102
103
104
 
 
105
106
107
...
92
93
94
 
95
96
97
98
99
100
101
102
103
 
 
104
105
106
107
108
0
@@ -92,16 +92,17 @@
0
     
0
     # Close any resource used by the response
0
     def close
0
- @body.close if @body === Tempfile
0
+ @body.delete if @body.class == Tempfile
0
     end
0
     
0
     private
0
       def move_body_to_tempfile
0
         current_body = @body
0
+ current_body.rewind
0
         @body = Tempfile.new(BODY_TMPFILE)
0
         @body.binmode
0
- @body << current_body unless current_body.size.zero?
0
- @env[RACK_INPUT] = @body
0
+ @body << current_body.read
0
+ @env[RACK_INPUT] = @body
0
       end
0
   end
0
 end
...
190
191
192
 
 
 
 
 
 
 
 
 
 
193
194
195
196
197
198
199
200
201
202
203
204
 
 
 
205
206
207
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
 
 
207
208
209
210
211
 
212
213
214
215
216
217
0
@@ -190,18 +190,28 @@
0
   end
0
   
0
   it "should move body to tempfile when too big" do
0
+ request = Request.new
0
+ request.parse("POST /postit HTTP/1.1\r\nContent-Length: #{Request::MAX_BODY*2}\r\n\r\n#{'X' * Request::MAX_BODY}")
0
+ request.parse('X' * Request::MAX_BODY)
0
+
0
+ request.body.size.should == Request::MAX_BODY * 2
0
+ request.should be_finished
0
+ request.body.class.should == Tempfile
0
+ end
0
+
0
+ it "should delete body tempfile when closing" do
0
     body = 'X' * (Request::MAX_BODY + 1)
0
     
0
     request = R(<<-EOS.chomp, true)
0
 POST /postit HTTP/1.1
0
-Host: localhost:3000
0
-Content-Type: text/html
0
 Content-Length: #{body.size}
0
 
0
 #{body}
0
 EOS
0
     
0
- request.body.class.should == Tempfile
0
+ request.body.path.should_not be_nil
0
+ request.close
0
+ request.body.path.should be_nil
0
   end
0
   
0
   it "should raise error when header is too big" do

Comments

    No one has commented yet.