11: def handle(ctx, params)
12: params[:response] = @response
13: body = StringIO.new
14: total = 0
15: @response.read_body { |part|
16: total += part.length
17: body.write(part)
18: Mechanize.log.debug("Read #{total} bytes") if Mechanize.log
19: }
20: body.rewind
21:
22: res_klass = Net::HTTPResponse::CODE_TO_OBJ[@response.code.to_s]
23: raise ResponseCodeError.new(@response) unless res_klass
24:
25:
26: unless res_klass <= Net::HTTPRedirection
27: raise EOFError if (!params[:request].is_a?(Net::HTTP::Head)) && @response.content_length() && @response.content_length() != total
28: end
29:
30: @response.each_header { |k,v|
31: Mechanize.log.debug("response-header: #{ k } => #{ v }")
32: } if Mechanize.log
33:
34: params[:response_body] = body
35: params[:res_klass] = res_klass
36: super
37: end