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:
200: if remain <= 0
201:
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:
207: if remain > Const::MAX_BODY
208:
209: @body = Tempfile.new(Const::MONGREL_TMP_BASE)
210: @body.binmode
211: else
212:
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