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:
206: @dispatchers.each do |dispatcher|
207: dispatcher.request_begins(@params)
208: end unless @dispatchers.nil? || @dispatchers.empty?
209:
210:
211: if remain <= 0
212:
213: @body = StringIO.new
214: @body.write @params.http_body
215: update_request_progress(0, content_length)
216: elsif remain > 0
217:
218: if remain > Const::MAX_BODY
219:
220: @body = Tempfile.new(Const::MONGREL_TMP_BASE)
221: @body.binmode
222: else
223:
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