196: def initialize(params, socket, dispatchers)
197: @params = params
198: @socket = socket
199: @dispatchers = dispatchers
200: content_length = @params[Const::CONTENT_LENGTH].to_i
201: remain = content_length - @params.http_body.length
202:
203:
204: @dispatchers.each do |dispatcher|
205: dispatcher.request_begins(@params)
206: end unless @dispatchers.nil? || @dispatchers.empty?
207:
208:
209: if remain <= 0
210:
211: @body = StringIO.new
212: @body.write @params.http_body
213: update_request_progress(0, content_length)
214: elsif remain > 0
215:
216: if remain > Const::MAX_BODY
217:
218: @body = Tempfile.new(Const::MONGREL_TMP_BASE)
219: @body.binmode
220: else
221:
222: @body = StringIO.new
223: end
224:
225: @body.write @params.http_body
226: read_body(remain, content_length)
227: end
228:
229: @body.rewind if @body
230: end