# File lib/mongrel.rb, line 198
198:     def initialize(params, socket, dispatchers)
199:       @params = params
200:       @socket = socket
201:       @dispatchers = dispatchers
202:       content_length = @params[Const::CONTENT_LENGTH].to_i
203:       remain = content_length - @params.http_body.length
204:       
205:       # tell all dispatchers the request has begun
206:       @dispatchers.each do |dispatcher|
207:         dispatcher.request_begins(@params) 
208:       end unless @dispatchers.nil? || @dispatchers.empty?
209: 
210:       # Some clients (like FF1.0) report 0 for body and then send a body.  This will probably truncate them but at least the request goes through usually.
211:       if remain <= 0
212:         # we've got everything, pack it up
213:         @body = StringIO.new
214:         @body.write @params.http_body
215:         update_request_progress(0, content_length)
216:       elsif remain > 0
217:         # must read more data to complete body
218:         if remain > Const::MAX_BODY
219:           # huge body, put it in a tempfile
220:           @body = Tempfile.new(Const::MONGREL_TMP_BASE)
221:           @body.binmode
222:         else
223:           # small body, just use that
224:           @body = StringIO.new 
225:         end
226: 
227:         @body.write @params.http_body
228:         read_body(remain, content_length)
229:       end
230: 
231:       @body.rewind if @body
232:     end