# File lib/mongrel.rb, line 190
190:     def initialize(params, socket, dispatcher)
191:       @params = params
192:       @socket = socket
193:       content_length = params[Const::CONTENT_LENGTH].to_i
194:       remain = content_length - params.http_body.length
195:       
196: 
197:       dispatcher.request_begins(params) if dispatcher
198: 
199:       # 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.
200:       if remain <= 0
201:         # we've got everything, pack it up
202:         @body = StringIO.new
203:         @body.write params.http_body
204:         dispatcher.request_progress(params, 0, content_length) if dispatcher
205:       elsif remain > 0
206:         # must read more data to complete body
207:         if remain > Const::MAX_BODY
208:           # huge body, put it in a tempfile
209:           @body = Tempfile.new(Const::MONGREL_TMP_BASE)
210:           @body.binmode
211:         else
212:           # small body, just use that
213:           @body = StringIO.new 
214:         end
215: 
216:         @body.write params.http_body
217:         read_body(remain, content_length, dispatcher)
218:       end
219: 
220:       @body.rewind if body
221:     end